Operating System - Linux
1828338 Members
3524 Online
109976 Solutions
New Discussion

removing spaces in the file starting at certain line number

 
SOLVED
Go to solution
Pando
Regular Advisor

removing spaces in the file starting at certain line number

dear gurus,

I have a file that needs to be stripped of spaces beginning at a certain line. For example, i need to strip only the white spaces beginning at line 10. I have found a perl script in this forum but it strips of the white spaces of the whole file. What i need is to strip white spaces beginning only at a certain line of my file.
Maximum points to all correct replies.
Thanks!
3 REPLIES 3
Rajeev  Shukla
Honored Contributor

Re: removing spaces in the file starting at certain line number

use
sed '10s/ //g' file > outputfile

Cheers
Rajeev
Peter Godron
Honored Contributor
Solution

Re: removing spaces in the file starting at certain line number

Fernando,
I believe Rajeev's solution should have been:
sed '10,$s/ //g' file > outputfile

The first part of the sed command in the original post would only replace spaces in line 10, whereas 10,$ means lines 10 to the end of the file.
Pando
Regular Advisor

Re: removing spaces in the file starting at certain line number

Thanks!