忽略来自find实用程序的文件我必须通过文件实用程序对我的目录和子目录中的文件进行排序,并制作10个最常用文件类型的图表。它运行使用grep -v
bash myfile -i [FILE_ERE]
所以FILE_ERE应该是每个文件和目录的正则表达式,应该在我的图中被忽略。例如,当发现是
testdirectory/hello1
testdirectory/hello2
testdirectory/NEWDIR/hello3
hello4
和论证我的$ FILE_ERE是 “目录”,它应该忽略每一个文件以 “DIR”,输出是
hello4
我有这个
input_name=$(file -b `find $DIR -type f | grep -v "$FILE_ERE"` | sort | uniq -c | sort -n -r | head | sed 's/^[ \t]*//' | cut -d' ' -f 2-)
input_number=$(file -b `find $DIR -type f | grep -v "$FILE_ERE"` | sort | uniq -c | sort -n -r | head | sed 's/^[ \t]*//' | cut -d' ' -f1)
但我的正则表达式是不是一些投入正常工作,就像FILE_ERE =“H”等
ROLF,最喜欢的家庭作业theese days ... http://stackoverflow.com/q/43028856/632407 – jm666