- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Deleting spaces at the end of line in a file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 11:49 AM
05-10-2002 11:49 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 11:55 AM
05-10-2002 11:55 AM
SolutionTry this link,
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xed737d4cf554d611abdb0090277a778c,00.html
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 11:57 AM
05-10-2002 11:57 AM
Re: Deleting spaces at the end of line in a file
# cat file | sed 's/[ \t]*$//' > newfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 12:02 PM
05-10-2002 12:02 PM
Re: Deleting spaces at the end of line in a file
cat myfile | perl -e 'while (
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 12:09 PM
05-10-2002 12:09 PM
Re: Deleting spaces at the end of line in a file
To get out of vi, ':wq!'. If you want to get out without saving, ':q!'.
Hope it helps
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 12:10 PM
05-10-2002 12:10 PM
Re: Deleting spaces at the end of line in a file
# delete trailing whitespace (spaces, tabs) from end of each line
sed 's/[ \t]*$//' # see note on '\t' at end of file
# delete BOTH leading and trailing whitespace from each line
sed 's/^[ \t]*//;s/[ \t]*$//'
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 12:36 PM
05-10-2002 12:36 PM
Re: Deleting spaces at the end of line in a file
Clay, glad you showed me a way in perl. Am learning perl and will try it.
Chan and Sachin, do appreciate it .
And John, thanks for the help but I am trying to do it globally.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 11:37 PM
05-10-2002 11:37 PM
Re: Deleting spaces at the end of line in a file
A.Clay, learn the command line switches:
cat myfile | perl -e 'while (
is equal to
perl -ple 's/\s+$//'
easier to read, ain't it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 11:40 PM
05-10-2002 11:40 PM
Re: Deleting spaces at the end of line in a file
Hit submit toooo early
cat myfile | perl -e 'while (
s/\s+/$// is illegal syntax, you mean s/\s+$//
in substitutions without extra flags, the $ in perl will match *before* the newline, so above (and my previous post) will add newlines
perl -pe 's/\s+$//'
should do. I now dropped the -l flag, which adds a newline to every print statement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2002 12:43 AM
05-11-2002 12:43 AM
Re: Deleting spaces at the end of line in a file
cat myfile|sed "s/[[:space:]]*$//" > newfile
It also handles all whitespace characters.
BTW - is this an Oracle spool file? If so you can suppress the spaces using
"SET TRIMSPOOL ON".
Graham