How to get files without certain strings in their files names (reverse of *string*) on Linux?

To get files with certain string in their file names, it is quite straightforward:

ls *string*

However, how to do the reverse one: how to get files without certain strings in their files names on Linux?

asked Jan 16, 2015 by anonymous

1 Answer

You can get a list of file names by a combination of find and xargs as follows:

find . ! -name '.' -and ! -name '*string*' | xargs

or by ls and grep as follows:

ls | grep -v string | xargs
answered Jan 19, 2015 by Eric Z Ma (44,280 points)
edited Jan 20, 2015 by Eric Z Ma

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...