Bash – All files in a directory that do not end in a specific string bashshellzsh I want to find all text files in a directory that do not end with the string: hello world How can I do this? Best Answer Try: for f in *; do if [ -f "$f" ] && [ "$(tail -n1 -- "$f")" != "hello world" ]; then printf '%s\n' "$f" fi done Related SolutionsBash – List all files containing a specific string find some/dir \ -exec grep -q "replace me" {} \; \ -exec cp some/new/filename.php {} \; Bash – Fastest way to open all files in a directory with multiple file extensions on commandline Simply call totem *.mp4 *.flv Too easy, isn't it ;-) Related QuestionHow to Display Characters Between Two Strings – Shell Scripting
Best Answer
Try: