Find all the filenames in this directory that do not contain 'a' 'b' or 'c' in their name [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-2
down vote

favorite













This question already has an answer here:



  • Why does `ls -d *[!e]*` display all files instead of omitting all files that contain an e?

    1 answer



I am trying to find all the files in my directory that does not contain the letters a,b or c; why does this command not work?



ls *[!abc]*


example: eg: MATCH: xyz, dkh, file, foo; NOT MATCH: bar, bxc, azi,csk










share|improve this question















marked as duplicate by Goro, Thomas, Romeo Ninov, agc, RalfFriedl Sep 23 at 11:59


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Would you please add more description. In addition, example and the expected output.
    – Goro
    Sep 22 at 19:15














up vote
-2
down vote

favorite













This question already has an answer here:



  • Why does `ls -d *[!e]*` display all files instead of omitting all files that contain an e?

    1 answer



I am trying to find all the files in my directory that does not contain the letters a,b or c; why does this command not work?



ls *[!abc]*


example: eg: MATCH: xyz, dkh, file, foo; NOT MATCH: bar, bxc, azi,csk










share|improve this question















marked as duplicate by Goro, Thomas, Romeo Ninov, agc, RalfFriedl Sep 23 at 11:59


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Would you please add more description. In addition, example and the expected output.
    – Goro
    Sep 22 at 19:15












up vote
-2
down vote

favorite









up vote
-2
down vote

favorite












This question already has an answer here:



  • Why does `ls -d *[!e]*` display all files instead of omitting all files that contain an e?

    1 answer



I am trying to find all the files in my directory that does not contain the letters a,b or c; why does this command not work?



ls *[!abc]*


example: eg: MATCH: xyz, dkh, file, foo; NOT MATCH: bar, bxc, azi,csk










share|improve this question
















This question already has an answer here:



  • Why does `ls -d *[!e]*` display all files instead of omitting all files that contain an e?

    1 answer



I am trying to find all the files in my directory that does not contain the letters a,b or c; why does this command not work?



ls *[!abc]*


example: eg: MATCH: xyz, dkh, file, foo; NOT MATCH: bar, bxc, azi,csk





This question already has an answer here:



  • Why does `ls -d *[!e]*` display all files instead of omitting all files that contain an e?

    1 answer







linux bash command-line filenames






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 22 at 19:25

























asked Sep 22 at 18:59









amendeep singh

112




112




marked as duplicate by Goro, Thomas, Romeo Ninov, agc, RalfFriedl Sep 23 at 11:59


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Goro, Thomas, Romeo Ninov, agc, RalfFriedl Sep 23 at 11:59


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • Would you please add more description. In addition, example and the expected output.
    – Goro
    Sep 22 at 19:15
















  • Would you please add more description. In addition, example and the expected output.
    – Goro
    Sep 22 at 19:15















Would you please add more description. In addition, example and the expected output.
– Goro
Sep 22 at 19:15




Would you please add more description. In addition, example and the expected output.
– Goro
Sep 22 at 19:15










1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










Your command does something very similar to what you want: it expands to the list of filenames that are not exactly: a, b, or c. If you test, you see:



$ touch a b c d
$ ls *[!abc]*
d


But if you create another file and re-test:



$ touch argh
$ ls *[!abc]*
argh d


To exclude file names that contain those characters anywhere, use:



$ shopt -s extglob
$ ls !(*[abc]*)
d


Another way of doing it (again with extended globs) would be to explicitly list out the patterns:



$ ls !(*a*|*b*|*c*)
d





share|improve this answer




















  • thanks thats exactly what i needed
    – amendeep singh
    Sep 22 at 19:32

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










Your command does something very similar to what you want: it expands to the list of filenames that are not exactly: a, b, or c. If you test, you see:



$ touch a b c d
$ ls *[!abc]*
d


But if you create another file and re-test:



$ touch argh
$ ls *[!abc]*
argh d


To exclude file names that contain those characters anywhere, use:



$ shopt -s extglob
$ ls !(*[abc]*)
d


Another way of doing it (again with extended globs) would be to explicitly list out the patterns:



$ ls !(*a*|*b*|*c*)
d





share|improve this answer




















  • thanks thats exactly what i needed
    – amendeep singh
    Sep 22 at 19:32














up vote
0
down vote



accepted










Your command does something very similar to what you want: it expands to the list of filenames that are not exactly: a, b, or c. If you test, you see:



$ touch a b c d
$ ls *[!abc]*
d


But if you create another file and re-test:



$ touch argh
$ ls *[!abc]*
argh d


To exclude file names that contain those characters anywhere, use:



$ shopt -s extglob
$ ls !(*[abc]*)
d


Another way of doing it (again with extended globs) would be to explicitly list out the patterns:



$ ls !(*a*|*b*|*c*)
d





share|improve this answer




















  • thanks thats exactly what i needed
    – amendeep singh
    Sep 22 at 19:32












up vote
0
down vote



accepted







up vote
0
down vote



accepted






Your command does something very similar to what you want: it expands to the list of filenames that are not exactly: a, b, or c. If you test, you see:



$ touch a b c d
$ ls *[!abc]*
d


But if you create another file and re-test:



$ touch argh
$ ls *[!abc]*
argh d


To exclude file names that contain those characters anywhere, use:



$ shopt -s extglob
$ ls !(*[abc]*)
d


Another way of doing it (again with extended globs) would be to explicitly list out the patterns:



$ ls !(*a*|*b*|*c*)
d





share|improve this answer












Your command does something very similar to what you want: it expands to the list of filenames that are not exactly: a, b, or c. If you test, you see:



$ touch a b c d
$ ls *[!abc]*
d


But if you create another file and re-test:



$ touch argh
$ ls *[!abc]*
argh d


To exclude file names that contain those characters anywhere, use:



$ shopt -s extglob
$ ls !(*[abc]*)
d


Another way of doing it (again with extended globs) would be to explicitly list out the patterns:



$ ls !(*a*|*b*|*c*)
d






share|improve this answer












share|improve this answer



share|improve this answer










answered Sep 22 at 19:26









Jeff Schaller

33.3k849111




33.3k849111











  • thanks thats exactly what i needed
    – amendeep singh
    Sep 22 at 19:32
















  • thanks thats exactly what i needed
    – amendeep singh
    Sep 22 at 19:32















thanks thats exactly what i needed
– amendeep singh
Sep 22 at 19:32




thanks thats exactly what i needed
– amendeep singh
Sep 22 at 19:32


Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay