Computing.Net > Forums > Unix > Remove blanks from a text file

Remove blanks from a text file

Reply to Message Icon

Original Message
Name: ros.ang
Date: November 22, 2004 at 05:34:50 Pacific
Subject: Remove blanks from a text file
OS: Digital Unix 4.0.F
CPU/Ram: Alpha / 1 Gb
Comment:

I need to remove trailing blanks from a text file . Each line is long 1024 characters and only the first part (about 100 char) is meaningful and I have some problems viewing the
informations with 'vi'.
Thanks to anyone for help


Angelo Rosinelli


Report Offensive Message For Removal


Response Number 1
Name: vicchai
Date: November 22, 2004 at 06:05:57 Pacific
Reply: (edit)

Try this:
cat text.txt | cut -c 1-100


Report Offensive Follow Up For Removal

Response Number 2
Name: Jim Boothe
Date: November 22, 2004 at 07:33:55 Pacific
Reply: (edit)

And to strip just the trailing blanks, one way is:

pr -t text.txt < text.new


Report Offensive Follow Up For Removal

Response Number 3
Name: vvenkatkalpana
Date: November 23, 2004 at 21:16:37 Pacific
Reply: (edit)

hi there u could use this sed command to remove trailing blank spaces!

sed 's/[ \t]*$//' filename


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Remove blanks from a text file

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge