Reputation: 303
I have a file which contains data like this:
1;2;3
4;5;6
7;8;9
....
n
where n is a random numer of lines. I'm trying to get from this file something like this:
command_1_command_2_command_3
command_4_command_5_command_6
....
n
Any suggestions how can I achieve this?
Upvotes: 1
Views: 69
Reputation: 8571
try this,
awk 'BEGIN {FS=";"}; {$1="command_"$1;$2="command_"$2;$3="command_"$3;print $1"_"$2"_"$3}' stacko.txt
nachiket@nachiket-X550LD:~$ cat stacko.txt
1;2;3
4;5;6
7;8;9
nachiket@nachiket-X550LD:~$ awk 'BEGIN {FS=";"}; {$1="command_"$1;$2="command_"$2;$3="command_"$3;print $1"_"$2"_"$3}' stacko.txt
command_1_command_2_command_3
command_4_command_5_command_6
command_7_command_8_command_9
nachiket@nachiket-X550LD:~$
Upvotes: 3