How can I list normal text (.txt
) filenames, that don\'t end with a newline?
e.g.: list (output) this filename:
$ cat a.txt
asdfasdlsad4rand
This should do the trick:
#!/bin/bash
for file in `find $1 -type f -name "*.txt"`;
do
nlines=`tail -n 1 $file | grep '^$' | wc -l`
if [ $nlines -eq 1 ]
then echo $file
fi
done;
Call it this way: ./script dir
E.g. ./script /home/user/Documents/
-> lists all text files in /home/user/Documents
ending with \n
.