Issue
I got a file with the following text -
observ1
observ1
observ1
observ1
observ1
What I need is a sed command that replace it to -
observ1
observ2
observ3
observ4
observ5
Or a sed command to add observ# in the beginning of each line for example -
file 1.txt -
hi
bye
see
you
soon
After said sed command -
observ1,hi
observ2,bye
observ3,see
observ4,you
observ5,soon
Thanks!
Solution
In 4 steps :
sed = a.txt | sed 'N;s/\n/,/' | sed 's/^/observ/' > b.txt
- numbering lines of the file
- add number + ',' at each line
- add prefix 'observ' at each line
- print result in new file
Answered By - Emerald Cottet Answer Checked By - Gilberto Lyons (WPSolving Admin)