Tuesday, January 3, 2012

find command syntax

The find command is very powerful, but sometimes it trips me up when I forget to escape parenthesis, or add space inside parenthesis or forget to quote paths which contain an asterisk.

Here are some of the cases that get me most often:

 
# the -path option expects the full path:
find . -path "py26/*" -print     #does not work
find . -path "./py26/*" -print   #works !

# find files in either directory 
find . -path "./py26/*" -o -path "./.git/*" -print

# same as the previous example, but using parenthesis '()'
find . \( -path  "./py26/*" -o -path "./.git/*" \) -print

# the above command won't work if we leave out the spaces after the first parenthesis and before the last one.
find . \(-path  "./py26/*" -o -path "./.git/*"\) -print

# find all files except for files in py26 or .git
find . \( -path  "./py26/*" -o -path "./.git/*" \) -prune -o -print


Note, you don't need to add the -print at the end of the command (it is used by default, but shown here for clarity)



2 comments:

Unknown said...

Your Affiliate Money Printing Machine is waiting -

Plus, making profit with it is as easy as 1..2..3!

It's super easy how it works...

STEP 1. Tell the system what affiliate products you want to push
STEP 2. Add some PUSH BUTTON traffic (this LITERALLY takes 2 minutes)
STEP 3. Watch the system explode your list and sell your affiliate products for you!

Are you ready to make money automatically???

Click here to make money with the system

Unknown said...

Do you understand there is a 12 word sentence you can say to your man... that will induce deep feelings of love and impulsive attractiveness to you deep within his heart?

Because hidden in these 12 words is a "secret signal" that fuels a man's instinct to love, treasure and care for you with all his heart...

12 Words Who Fuel A Man's Desire Instinct

This instinct is so hardwired into a man's brain that it will make him work better than ever before to make your relationship as strong as it can be.

In fact, triggering this influential instinct is so binding to getting the best possible relationship with your man that as soon as you send your man a "Secret Signal"...

...You'll soon find him open his heart and soul for you in such a way he haven't experienced before and he will identify you as the only woman in the universe who has ever truly understood him.