我有一个脚本可以在文件中搜索许多不同文件夹中的短语,然后显示输出。
麻烦的是,它按顺序搜索并花费很长时间。我想在不等待前一个搜索完成的情况下运行搜索。
zipped_folders=("/extlogs/archive/rsyslog/folder1/"
"/extlogs/archive/rsyslog/folder2/")
folders=("/extlogs/rsyslog/Folder1/"
"/extlogs/rsyslog/Folder2/")
portal=0
mobile=0
email=0
if [ "$#" -ne 1 ]; then
echo "Incorrect Argument: logcount 201602"
exit 1
fi
for i in "${zipped_folders[@]}"
do
#echo $i"syslog-"$1*".log.gz"
((portal+=$(nohup gunzip -c $i"syslog-"$1*".log.gz" | grep -i "search1" | grep -v "Search1" | wc -l &)))
((mobile+=$(nohup gunzip -c $i"syslog-"$1*".log.gz" | grep -i "Search2" | wc -l &)))
((email+=$(nohup gunzip -c $i"syslog-"$1*".log.gz" | grep -i "search3" | grep -v "ActiveSync" | wc -l &)))
done
for i in "${folders[@]}"
do
((portal+=$(nohup cat $i"syslog-"$1*".log"| grep -i "search4"| grep -v "exsearch4" | wc -l &)))
((mobile+=$(nohup cat $i"syslog-"$1*".log" | grep -i "search5" | wc -l &)))
((email+=$(nohup cat $i"syslog-"$1*".log" | grep -i "search6" | grep -v "ActiveSync" | wc -l &)))
done
echo "Portal: " $portal
echo "Mobile: " $mobile
echo "Email: " $email
exit 1
答案 0 :(得分:1)
您可以使用@Override
public synchronized void drop(DropTargetDropEvent dtde) {
if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
Transferable t = dtde.getTransferable();
List fileList = null;
try {
fileList = (List) t.getTransferData(DataFlavor.javaFileListFlavor);
if (fileList != null && fileList.size() > 0) {
for (Object value : fileList) {
if (value instanceof File) {
File f = (File) value;
if (row < 0) {
model.addRow(new Object[]{f.getAbsolutePath(), "", f.length(), "", ""});
} else {
model.insertRow(row, new Object[]{f.getAbsolutePath(), "", f.length(), "", ""});
row++;
}
}
}
}
} catch (UnsupportedFlavorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else {
dtde.rejectDrop();
}
}
。
xargs