Find the answer to your Linux question:
Results 1 to 4 of 4
Originally Posted by wassy121 you can run -exec with multiple commands, but not multiple -exec flags. For instance: find . -name "*.txt" -exec ls {} \&\& ls {} \; Hello ...
  1. #1
    Just Joined!
    Join Date
    Jan 2008
    Posts
    2

    -exec?

    Quote Originally Posted by wassy121 View Post
    you can run -exec with multiple commands, but not multiple -exec flags. For instance:
    find . -name "*.txt" -exec ls {} \&\& ls {} \;
    Hello Wassy, no unfortunately that won't work, at least here on my ubuntu this happens:
    Code:
    find . -name "*.mp3" -exec ls {} \&\& ls {} \;
    ./stuff/test.mp3 ./stuff/test.mp3
    ls: &&: No such file or directory
    ls: ls: No such file or directory
    and same especially with "|".

    Anyone knows how to solve this? I actually would like to be able to do an exiftool of some files, and directly save a log of its result in the same folder, but using | and tee will result as the example above, and using ">" will save in the folder I'm running find in.

    Any help welcome!

    Vorrin Tal
    Last edited by devils casper; 01-16-2008 at 05:59 PM. Reason: added [code].......[/code] tags

  2. #2
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    Example using multiple -exec directives:
    Code:
    find . -name '*.doc' -exec file {} \; -exec ls -l {} \;
    Last edited by devils casper; 01-16-2008 at 05:59 PM. Reason: added [code].......[/code] tags

  3. #3
    Just Joined!
    Join Date
    Jan 2008
    Posts
    2
    Thanks anomie!

    That's already a step forward, but it still won't log the output of the previous command... basically what I would need is for this to work:


    Code:
    find . -name '*.doc' -exec file {} \| tee test.log  \;
    Last edited by devils casper; 01-16-2008 at 06:00 PM. Reason: added [code].......[/code] tags

  4. #4
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    A sample how to use the file command for the found files and write the output of the found files to your logfile:

    Code:
    file $(find . -name '*.doc' | tee test.log)
    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...