News for hackers. Stuff that matters.
Re:Linux Commands for Developers by yogione on Wednesday August 29, 2012 @07:11AM (#4447959)
how do I execute the out put of something like this:

grep -i 'pattern' file | awk '{print $5}' | sed 's/^/cmd/g'

I end up sending to a file, chmod, then run it at the shell.

Re:Linux Commands for Developers by michaelcampbell on Wednesday August 29, 2012 @07:32AM (#4448009)
In bash...

    $(grep -i 'pattern' file | awk '{print $5}' | sed 's/^/cmd/g')
?

Or surround in backticks

    `command which outputs text you want to run as a command`
I prefer $() as they nest better.

Or have I misunderstood your question?

Re:Linux Commands for Developers by yogione on Wednesday August 29, 2012 @08:59AM (#4448252)
That's it $() works. thanks.
Re:Linux Commands for Developers by badboy on Wednesday August 29, 2012 @07:27AM (#4448001)
Wrap it in $() to execute. And even if you pipe it into a file, no chmod is required. "sh file" works as it should
Re:Linux Commands for Developers by slug on Wednesday August 29, 2012 @07:45AM (#4448048)
or use eval

~$ help eval eval: eval [arg ...] Execute arguments as a shell command.

    Combine ARGs into a single string, use the result as input to the shell,
    and execute the resulting commands.
   Exit Status:
    Returns exit status of command or success if command is null.
Re:Linux Commands for Developers by Domenic_S on Wednesday August 29, 2012 @12:15PM (#4449344)
xargs instead of that sed (I assume you're prepending your command to run there).

grep -i 'pattern' file | awk '{print $5}' | xargs cmd