RE: Sed, awk?

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

 



I too am having a bit of a problem underestanding what you are asking . Do
you want
all the output to be on one line instead of one entry per line?  It really
shouldn't matter what kind of white space you pipe in to your next program.
Whitespace is pretty much whitespace (newline vs space).

Anyway, try something like this.

1) grep 'alsdjf' * | awk -F: '{print $1}' | xargs echo -n

if uniqueness is an issue, then use htis:

2) grep 'alsdfj' * | awk -F: '{print $1}' | uniq | xargs echo -n

In 1) if "alsdjf" appears morethan one in the file, then the filename will
come up twice in your grep statement.  if that's not what you want, then use
2)

explanation:
------------
awk -F:  ----> (use colon as the field separator)
'{print $1}' ----> (print the first column ) (similar to your php explode)
| xargs  ----> (take all the output )
echo -n ----> (echo without newline )

let me know if that's what you're looking for


Cheers-
Ben Y



== Original Message Follows ==
grep 'alsdjf' * | cut -f 1 -d :

Returns all the filenames:what I'm searching for, growing rapidly,
right now the line count is around 200. What I want to do with this
output is input it into a script I made, which contains sa-learn
--args.. $*, where $* is the output from grep and cut.

I need the output from grep and cut to be all on the same line, not
the 200+ as it currently is.

So, is there a way to have the output from grep and cut to be all on
one big line seperated by spaces?

Thanks,
Jake


-- 
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