How to print arguments along with spaces using awk

Hi All,

file_1.txt contains

aaa bbbb hhhh
vvvvv mmmmm iiiii

What i want is to search for the first coloumn of each line using awk.i.e as below:

awk '/aaa/ {printf(<>)}' file_1.txt

The print part (<>) should contain all the values(or coloumns ) in the particular line(here it is: bbbb hhhh) including the spaces between each arguments.Given that the "aaa" should not be printed.

In short my output after running the above awk should be
bbbb hhhh

If it is the "vvvv" am searching for then the result should be
mmmmm iiiii

Thanks in advance
JS

awk '/aaa/ {print $2, $3}' file_1.txt

This command prints only one single space between each arguments.Not all the spaces!!!

jisha you need to be more polite , Yogesh was trying to help u.

First , your regex in wrong it'll macths all lines that contains the "aaa" not only first column,...
anyway many ways to do , one could be:

awk '/^aaa/{sub(/^aaa */,"",$0);print}' file
awk 'sub(/^aaa/,"")' filename

I'm not sure if you want the space after the pattern (if any),
in that case:

awk 'sub(/^aaa */,"")' filename

Dear God .. I never meant anything unpolite ..I just said how it worked out .. And i was in a very tight situation yesterday that i missed to put the thanks .. Sorry for that. .

Thank you Yogesh ..

Thank you Klashxx

but code doesnot print the spaces in the begining .. Also when i ran this in command promt other than the starting spaces everything else is working .. But am supposed to run this in a script where the pattern is received from a function call .. When i executed the script, i got error saying unamatched ..

The fields in the file are unique ..Nothing is repeated ..Also the pattern for matching is always at teh first of coloumn in my file ..

Once again thanks for the effort ...
JS

HI radoulov,

Thank you for the reply ..
Finally i have made it as given below :

awk 'sub(/^('"${name}"')/,"")'

Regards,
JS