i need help using awk. Thanks
i have a file it contains the following
text.txt
The Hunger Games:Suzanne Collins:1:2:3
Weapon X:Stan Lee:3:4:5
>
Try this to get tab spacings as in your example:
awk -F: '{if(NR==2)$2="\t"$2;print $1, $2, $3, $4, $5}' OFS="\t" BookDB.txt
Setting :
as field seperator and \t
as output field seperator. Then for the second line (NR==2)
, add one extra tab
for the second field. Then print the fields.
Or even simpler (if it is acceptable for you):
sed "s/:/\t/g" BookDB.txt