Find the answer to your Linux question:
Results 1 to 6 of 6
I have a question about a set of commands. find ~ -type f -name "*pdf" -print0 | xargs -0 -i ln -fs {} ~/Documents/pdfs/ I would like to implement the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2012
    Posts
    5

    Linux command for MacOSX :options for xargs


    I have a question about a set of commands.

    find ~ -type f -name "*pdf" -print0 | xargs -0 -i ln -fs {} ~/Documents/pdfs/

    I would like to implement the command above. But for some reason, it does not work with MacOSX (SnowLeopard).

    It seems like options for xargs differ depending on the environment. But I have no Linux environment right now, can anyone interpret it in the language of MacOS?

    soichi

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Hello and welcome!

    For starters, it appears that MacOSX (that is, BSD) xargs does not support the "-i" flag:

    http://developer.apple.com/library/m...1/xargs.1.html

    Compare it to the xargs man page for Linux:

    http://linux.die.net/man/1/xargs

    But i'm not sure if that is your problem.

    Can you post what you get when you run the command?
    Last edited by atreyu; 11-11-2012 at 04:31 AM. Reason: fixed links

  3. #3
    Just Joined!
    Join Date
    Nov 2012
    Posts
    5
    Quote Originally Posted by atreyu View Post


    Can you post what you get when you run the command?
    If I do the command I posted above, I get

    xargs: illegal option -- i
    usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
    [-L number] [-n number [-x]] [-P maxprocs] [-s size]
    [utility [argument ...]]


    If I do it without "-i", I get

    usage: ln [-Ffhinsv] source_file [target_file]
    ln [-Ffhinsv] source_file ... target_dir
    link source_file target_file

    it looks like the pipe does not pass the arguments to ln properly...but I am not sure.

    soichi

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    How about this dog, will it hunt?
    Code:
    find ~ -type f -name "*pdf" -exec ln -svf {} ~/Documents/pdfs/ \;

  6. #5
    Just Joined!
    Join Date
    Nov 2012
    Posts
    5
    Quote Originally Posted by atreyu View Post
    How about this dog, will it hunt?
    Code:
    find ~ -type f -name "*pdf" -exec ln -svf {} ~/Documents/pdfs/ \;
    I did work! Thanks!

    soichi

  7. #6
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Cheers! Marking thread as Solved for you.

Posting Permissions

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