Tuesday, January 21, 2014

Remove line numbers from source code using sed

While getting sample code from internet, it may comes with line number. To simply remove those lines from the code file use the below ways.

Using sed command with RegEx pattern in Linux, that can be achieved.

To remove it from console:
$ sed -i "s/^ *[0-9.]* *//g" code.txt
To remove it from vim interface:
:%s/^ *[0-9.]* *//g
And the same RegEx pattern can be used in anywhere to remove the line numbers from the source code file.

 

No comments:

Post a Comment