Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
need help for sed
Name: jds Date: February 5, 2008 at 13:38:27 Pacific OS: windowsXP CPU/Ram: petium III/ram 256
Comment:
Hi, I am trying to add line number in front of each line for a file. I tried this : # number each line of a file (number on left, right-aligned) sed = filename | sed 'N; s/^/ /; s/ *\(.\{6,\}\)\n/\1 /'
But this command give me line number like bellow: 1 asdasdas 2 sdfsdfsd .... 10 sdfasdf 11 sdfsdf
How can make the line number like this: 1010 asdasdas 1020 sdfsdfsd .... 1110 sdfasdf 1120 sdfsdf ... basicly do some math to it:) Thanks in advance
Name: nails Date: February 5, 2008 at 21:36:41 Pacific
Reply:
I see no way of solving your problem with sed. It's definitely possible with awk; simply create two variables - one with the starting integer, and the other with the increment. Simply cycle thru the file, printf the beginning integer, and increment the integer by the increment variable printf'ing each line.
0
Response Number 2
Name: Luke Chi Date: February 7, 2008 at 13:37:24 Pacific
Name: jds Date: February 9, 2008 at 21:53:14 Pacific
Reply:
Thanks very much Nails and Luke. The Luke's way perfect solved my issue. I did reply a few days ago but for some reason it sidn't posted successfully. Anyway, thanks very much
0
Response Number 4
Name: Luke Chi Date: February 12, 2008 at 17:33:34 Pacific
Reply:
Glad to hear that
Luke Chi
0
Response Number 5
Name: malli.eskala Date: February 18, 2008 at 04:37:08 Pacific
Summary: Hi All, I found this post from a few years ago. My question is Can I do it a litlle bit further: I wan to find out the first letter start with P and replace text( numbers) from 23rd to 26th, 43 to 46,...
Summary: I'm playing with java, python, sed to get this done but couldn't, so far. Thats why I might have commited mistake while giving you data file. I appolozise for that. This time scripts worked great and ...
Summary: Hi I need help with sed , i figured out how to use it but i need a way for it to remove "." and "/" like in this example SRC="../../../xxxxxxx/xxxx and make it SRC="./xxxxxxx/xxxx so basically i nee...