Awk: splitting a field -
new awk , try that's simple it's taking me while. simplify things, have text file called 'sample' , contains following line:
164516454242451bx%apt 110 225 1784 ohio usa
i want following output using awk:
apt 110 225
is there way can split $1 "apt" separate field? code i'm trying below. recieve no error, output 2 blank lines.
awk ' begin { split($1," ","%") } print $2,$3,$4 end { print "" } ' sample
you can %
1 of delimiters:
awk -f'[ %]' '{print $2, $3, $4}' file
the same can done using split well:
awk '{split($1,a,/%/); print a[2], $2, $3}' file
Comments
Post a Comment