Hi Folks,
I have a huge data of the below format
abc #apple 1200 06/23
ghj #orange 1500 06/27
uyt #banana 2300 05/13
efg #vegetable 0700 04/16
After first 3 letters, i have 9 spaces and after fruit there are no specific fixed space, but it varies accroding to the length of the fruit name.
Now my requirement is like i must get the data like below.
abc#apple(1200 06/23)
ghj#orange(1500 06/27)
uyt#banana(2300 05/13)
efg#vegetable(0700 04/16)
How can i achieve this ?
Thanks
Jay
try
nawk '{gsub($3,"("$3,$0); gsub($4,$4")",$0); gsub(" ","",$0); print}' file
Can't just
akshay@Aix:/tmp$ cat file
abc #apple 1200 06/23
ghj #orange 1500 06/27
uyt #banana 2300 05/13
efg #vegetable 0700 04/16
akshay@Aix:/tmp$ awk '{print $1 $2 "(" $3 , $4 ")"}' file
abc#apple(1200 06/23)
ghj#orange(1500 06/27)
uyt#banana(2300 05/13)
efg#vegetable(0700 04/16)
---------- Post updated at 07:58 PM ---------- Previous update was at 07:56 PM ----------
This removes space in whole line
---------- Post updated at 07:59 PM ---------- Previous update was at 07:58 PM ----------
and output would be something like this
abc#apple(120006/23)
ghj#orange(150006/27)
uyt#banana(230005/13)
efg#vegetable(070004/16)
have you tried command given by Akshay
awk '{print $1 $2 "(" $3 , $4 ")"}' file