1

I would like to list all files in folder without one. I created this command ls /Users/MartinBengsch/Library/Safari | grep ! "Extensions". The problem is that the Terminal doesn't understand the not (!). How to change that it works?

Thanks!

4

You might do it like this:

ls /path/to/folder | grep -v "Extensions"

grep -v "Extensions" excludes "Extensions" from the listing.

  • With removing grep -n "" it is what I mean, thanks! :) – user121028 Jul 7 '15 at 10:48
  • grep -n adds line numbers :-) – nohillside Jul 7 '15 at 10:58
  • How do I integrate -exec in the command line? – user121028 Jul 7 '15 at 10:58
  • @user121028 That is a separate question - find is the command you need to read the manual/tutorial for – Mark Jul 7 '15 at 11:54
1

You can turn on extended glob in bash.

    shopt -s extglob
    cd $HOME/Library/Safari
    ls -d -- !(Extentions)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .