I have to sort files in my directory and subdirs by file utility and make diagram of 10 most frequent file types. It runs by
bash myfile -i [FILE_ERE]
so the FILE_ERE should be regex for every file and directory that should be ignored in my diagram. For example, when find out is
testdirectory/hello1
testdirectory/hello2
testdirectory/newdir/hello3
hello4
and my $FILE_ERE from arguments is "dir", it should ignore every file with "dir" and the output is
hello4
I have this
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)
But my regex isn't working correctly for some inputs, like FILE_ERE="ˆh" etc.