1

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?

5
  • 1
    Looks easy to do with awk. Give it a try, and post what you have if you can't get it working. Commented Sep 11, 2014 at 17:48
  • Does the file really contain bullets at the beginning of each line? Commented Sep 11, 2014 at 17:50
  • Of course not. I had problems with text formatting - now It's correct :) Commented Sep 11, 2014 at 17:51
  • It should also be simple using sed. Replace the beginning of the line with command_, and replace ; with _command_. Commented Sep 11, 2014 at 17:52
  • Thx. Will try this tomorrow morning @ work :) Commented Sep 11, 2014 at 17:54

1 Answer 1

3

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:~$ 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.