Thanks! Would there be a way to get them all on one line instead ofecho $(oneliner | grep 'whatever' | cut -f1 -d:)
many, seperated by a space for input to another command? Being they
are all on their own lines, it's kind of messy for input to another
command.
or
echo $(oneliner | awk -F: '/whatever/' {print $1}')
or
echo $(oneliner | sed -n '/whatever/s/:.*//p')
or
echo $(oneliner | perl -ne 'if (/whatever) {split(/:/); print @_[0] . "\n"}')
or
echo $(for i in $(oneliner | grep '/whatever/'); do echo "${i%:*}"; done)
(This last one has problems when "oneliner" produces lines that match the RE that contain spaces, but that's fixable.)
Replace "echo" with the command of your choice.
How many different ways would you like? This is Unix :-) I got bored thinking up different ways.
Actually, I've just noticed you said:
oneliner | grep 'whatever' *
In this case grep looks for whatever in all the files in the current directory. What's the purpose of "oneliner"? Or is the "*" an oversight.
jch
-- Shrike-list mailing list Shrike-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/shrike-list