Read a word in a string with bash
Hi all!!!
Today i've got a new problem. I'm Trying to extract a word from a string that look like that: "695856 5859 66:55:66 99:77:55" In fact i want a command that would allow me to extract, for example, the third word (here 66:55:66) Thanks |
awk seems just right for that, eg:
awk '{print $3}' Yves. |
Ok thank you Yves.
but where do i specify the string to be used? |
awk reads from standard input or from a file (much like sed). So if your text is in a file, then this will do:
Code:
awk '...' a_file Code:
other_commands | awk '...' - Long text: Code:
awk '...' <<-FIN Code:
awk '...' <<<"text with ${var} if you want" |
Ok but i can use the pipe (other command | awk ... ) in my script, it makes no difference, does it?
|
Pipe is OK.
|
thanks, it work just as i excpected!!!
|
All times are GMT -5. The time now is 12:11 AM. |