I can search for a word in the file by using grep
for example:
grep 'total energy' file*
but I can't search for a word with =
, for example:
grep 'total energy =' file*
Why? is there any solution to above issue?
I can search for a word in the file by using grep
for example:
grep 'total energy' file*
but I can't search for a word with =
, for example:
grep 'total energy =' file*
Why? is there any solution to above issue?
You have to use double quotes (""
) like this
grep "total energy =" /your/file
where you substitute /your/file
with the name of your file. Read difference between ""
and ''
.
To search through all files in current directory, you want the next command
find ./ -type f -exec grep "total energy =" {} \;
What this does is it first finds all files in current dir using find
(./
denotes current directory, -type f
stands for only files). Then it executes grep
search for "total energy ="
. \
denotes where the end of -exec
is, in case there would be anything else behind it.
If you only want to search through files that are like frame[number].inp
, you can use regex with find
:
find ./ -regextype posix-extended -regex '.*?\.inp' -exec grep "total energy =" {} \;