Find the answer to your Linux question:
Results 1 to 4 of 4
I've been able to get the right output that I need from sed, but how can I execute the string that sed actually outputs?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2010
    Posts
    9

    [SOLVED] executing sed's output


    I've been able to get the right output that I need from sed, but how can I execute the string that sed actually outputs?

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    If you use the "`" apostrophes, the output of the command will be executed.
    You can also use xargs.
    Debian GNU/Linux -- You know you want it.

  3. #3
    Linux Newbie theNbomr's Avatar
    Join Date
    May 2007
    Location
    BC Canada
    Posts
    155
    The 'apostrophes', usually referred to as 'backticks' are used by the shell to transform standard output into a commandline argument. Backticks have been deprecated in favor of the the $(command) format. Bash in most distros now supports this format.
    Example:
    Code:
    echo "ls -la"
    $(echo ls -la)
    The first command simply emits the string "ls -la", while the second command actually invokes that command. Not an efficient way to use the feature, but does demonstrate the principle.

    As GNU-Fan correctly points out, xargs can also be used, and is probably a better option if the result of your sed command can be a very long list of arguments.

    man xargs

    --- rod.
    Stuff happens. Then stays happened.

  4. #4
    Just Joined!
    Join Date
    Apr 2010
    Posts
    9
    thanks for the xargs suggestion; worked great!

Posting Permissions

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