I have a file looking like the following:
abcdefghijklmnopqrst
//
abcdefghijklmnopqrst
//
abcdefghijklmnopqrst
I use the following code to insert a line with // to the beginning of the document (as advised here: Adding text to beginning of text file), and save this update to a new file.
sed '1s/^/\/\/\'$'\n/' File_1.txt > File_2.txt
What I would like to do, however, is to add unique names after each //, getting a result like this:
// Text 1
abcdefghijklmnopqrst
// Text 2
abcdefghijklmnopqrst
// Text 3
abcdefghijklmnopqrst
etc.
I was thinking I could use tr to translate eg. "//" into "// Text 1". But how do I add Text 2 to the next //, text 3 to the third // etc.? I am complete newbie at this. The txt file is mac-osx made.
Thank you!
Aucun commentaire:
Enregistrer un commentaire