Re: Sed, awk? [solved]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jake McHenry wrote:

> I then need that input to go into the spam.spam or spam.ham files as
> if I typed it all like:
> 
>   spam.spam file1 file2 file3 file4
> 
> I can't figure out how to do this part, as I tried:
> 
>   grep 'nittany' * | cut -f 1 -d : | tr \\012 \\40 | spam.spam
> 
> And
> 
>   spam.spam | grep 'nittany' * | cut -f 1 -d : | tr \\012 \\40
> 
> Neither worked.

Of course not. With a pipe (the | symbol) the output of the first (left)
command is piped into the *standard input* (STDIN) of the second (right)
command. But you need the output as *arguments* of your command. The
solution is a subshell, usually done with backticks``. Caution: These
backticks are *not* the apostrophe (also called single quote) ' but the
accent grave!
So try
spam.spam ` grep -R 'email' * | awk -F: '{print $1}' | uniq | xargs \
echo -n `
(the backslash \ makes this work with the line break, if you issue it on
one line, just omit it) and
spam.spam ` grep 'nittany' * | cut -f 1 -d : | tr \\012 \\40 `

Best regards,
Martin Stricker
-- 
Homepage: http://www.martin-stricker.de/
Linux Migration Project: http://www.linux-migration.org/
Red Hat Linux 9 for low memory: http://www.rule-project.org/
Registered Linux user #210635: http://counter.li.org/


-- 
Shrike-list mailing list
Shrike-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/shrike-list

[Index of Archives]     [Fedora Users]     [Centos Users]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat Phoebe Beta]     [Yosemite Forum]     [Fedora Discussion]     [Gimp]     [Stuff]     [Yosemite News]

  Powered by Linux