I have an assignment and it asks me to

Display files in /usr/bin that do not begin with a through v

it then asks me to

Display files in /usr/bin that contains at least two numeric digits

I've tried everything I could think of, I cant figure these two commands out.


Use find:

find /usr -not -name "v*" -type f

-name lists all files which match v and then arbitrary characters

-not inverts this

-type f only lists files, not directories

find /usr/bin -type f  -name "*[0-9]*[0-9]*" 

the same as above [0-9] stands for one arbitrary digit, the asterisks ( * ) for arbitrary characters in between, before and after the digits.

Don't forget the quotation mark, otherwise the name expression is not evaluated by find for the results, but by the shell, before they get passed to find

  • This will list files in the subfolders as well. if this is not desired, add -maxdepth 1 to the command or use ls – Jounathaen Feb 8 '17 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.