I'm looking to display 3 different files, if they exist. I thought the following would work, but it doesn't:
ls -R | grep 6-atom2D.vector$ 6-atom2D.klist 6-atom2D.struct
How can I do it?
Knowing the (base) filenames, you can use find
:
find . -name '6-atom2D.vector$' -o -name '6-atom2D.klist' -o -name '6-atom2D.struct'
It searches recursive by default. For case-insensitive search, use -iname
instead.
ls -R | egrep "6-atom2D\.vector$|6-atom2D\.klist|6-atom2D\.struct"
If $
is supposed to be end of line regexp, then you might need to use \\>
instead. That works for me at least.
Edit: Backslash before .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.