Possible Duplicate:
How can I use inverse or negative wildcards when pattern matching in a unix/linux shell?
I've read the man
page for ls
, and I can't find the option to list all that do not match the file selector. Do you know how to perform this operation?
For example: lets say my directory is this:
> ls
a.txt b.mkv c.txt d.mp3 e.flv
Now I would like to do something that does the following
> ls -[SOME_OPTION] *.txt
b.mkv d.mp3 e.flv
Is there such an option?
If not, is there a way to pipe the output of ls
to another function (possibly sed
) that shows only the ones that I would like?
I don't know exactly how to do this, but I'm imagining it would be something like:
> ls | sed [SOMETHING]
I really should learn how to use sed
,awk
,and grep
, but I keep getting stuck at understanding how to write the regexes. I understand the concept of regular expressions clearly, but I get confused between regexes that use different syntax.
Any help would be much appreciated!
EDIT:
I forgot to mention that I am running Mac OS X, so the functions may be slightly different from the ones discussed in other answers for the unix/linux shell (hence some of my confusion with sed
,awk
,and grep
).
When searching for certain file types that does not contain certain text or strings, you can use this command: >> find /home/example -iname "*. txt" -exec grep -Li "mystring" {} \+ This will list all text files that do NOT contain the term "mystring".
Linux ls command options The (ls -a) command will enlist the whole list of the current directory including the hidden files. It will show the list in a long list format. This command will show you the file sizes in human readable format. Size of the file is very difficult to read when displayed in terms of byte.
this may be help you
ls --ignore=*.txt
It will not display the .txt files in your directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With