Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ls --ignore on osx

Tags:

bash

macos

ls

I'm trying to do the following on OSX:

ls -lR --ignore *.app

So that I can recursively search through all folders except for .app folders.

However it seems there is seems to be no --ignore or --hide options in Darwin.

Perhaps a script to recursively search one folder deep for a given set and I'm not sure I cant pipe ls -lR through anything because of the format of the output:

./ROOT/Applications/Some_app:
drwxr-xr-x   3 admin  root  102 26 Jun 11:03 app-bundle.app  #<- WANT THIS
drwxr-xr-x@ 24 admin  root  816 26 Jun 11:24 folder          #<- WANT THIS

./ROOT/Applications/Some_app/app-bundle.app:                 #<- DON'T WANT
drwxr-xr-x  7 admin  root  238 26 Jun 11:03 Contents         #<- DON'T WANT
...
like image 438
hoss Avatar asked Jun 26 '12 18:06

hoss


People also ask

How do you do ls commands on a Mac?

While you're there—or when you're in any folder (directory in Unix-speak)—you might want to know what's in it. To do that you use the ls (or list) command. Type ls and press the Return key, and you'll see the folders (and/or files) in the current directory.

What does ls stand for Mac terminal?

The ls command is used to list files. "ls" on its own lists all files in the current directory except for hidden files.


2 Answers

An alternative is to pipe to grep:

ls | grep -v

like image 162
Oath Avatar answered Sep 29 '22 10:09

Oath


Use find:

find . -ls -name '*.app' -prune
like image 45
Rob Napier Avatar answered Sep 29 '22 12:09

Rob Napier