Operating System - Linux
1751922 Members
4984 Online
108783 Solutions
New Discussion юеВ

Re: command for no-listing

 
SOLVED
Go to solution
Stanimir
Trusted Contributor

command for no-listing

Hi!
I have a simple question - how I could
list all files in directory, which is not matched a certain filter.
Something like "anti-grep"-command.

Regards.
4 REPLIES 4
Kasper Hedensted
Trusted Contributor
Solution

Re: command for no-listing

Hi,

won't "grep -v" do ?

Cheers,
Kasper
Muthukumar_5
Honored Contributor

Re: command for no-listing

You can do with grep -v or egrep -v or with awk.

ls | grep -v 'string'
ls | awk '!/string/ { print $0 }'

hth.
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: command for no-listing

IF you want to do multiples strings then,

ls | grep -Ev 'string1|string2|..'
ls | egrep -v 'string1|string2|..'

hth.
Easy to suggest when don't know about the problem!
Stanimir
Trusted Contributor

Re: command for no-listing

OK, great job!