input
a 100 200 300
b 400 10
output
a 100
a 200
a 300
b 400
b 10
Thanx
input
a 100 200 300
b 400 10
output
a 100
a 200
a 300
b 400
b 10
Thanx
Are you writing any book on awk oneliner or testing forum members skill set...??
Just kidding here you go..
awk '{split($0,A)}{for(i=2;i<=NF;i++){print A[1]" "A}}' filename
haha.
Always I would try to go with or write precise answers for any problems I come across.
actually I tried solving the problem above for a while. But quiet didn't get it though managed with some ugly code. Finally I posted with lot of hesitation.
In last post post I solved my problem my self and posted along with the problem. (some one moked at my code coz its bit ugly). Anways he gave the best code.
this forums helps me understanding awk and others but some times finding hard at the attitude of few.(you not on the list haha)
# awk '{for (i=2;i<=NF;i++){print $1,$i}}' infile
a 100
a 200
a 300
b 400
b 10
HTH
Or:
awk '{
for (i=2; i<=NF; i++)
print $1, $i
}' infile
Edit: Just saw Tytalus already provided the same answer.
@radoullov ##How could I give you bonus points. yesterday I have seen some one credited with bonus points for answering my post.
You been really helpful every time.
Mr.Vidya is already in Moderator mode. but kudos to him too
Perl:
perl -ane'
print map "$F[0] $_\n", @F[1..$#F]
' infile
---------- Post updated at 11:36 AM ---------- Previous update was at 11:32 AM ----------
By clicking on this link
But don't worry, managing to provide a correct answer is enough for me.