Using find with -exec for multiple commands

Contrary to the most prevalent example I could find, the following method of stringing commands together using find -exec didn’t work:

find . -name ‘*.txt’ -exec ls -l {} \&\& file {} \;
it resulted in lots of:
ls: &&: No such file or directory
ls: file: No such file or directory

Thanks again to #gllug and in particular Leeds the correct format is:

find . -name ‘*.txt’ -exec ls {} \; -exec file {} \;

and use -L for following symlinks

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s