- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: trimming a large 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
01-15-2003 05:42 AM
01-15-2003 05:42 AM
I am attempting to trim quite a large file.
the file has entries like the following :
1234|abcd|defg|one
5678|abcdefg|1|6
etc.....
but because the file was created in SQLPLUS using a large column format, there are lots of whitespaces after the last pipedelimitted field. What I was trying to do is trim this so all that remains is the pipe del'd fields.
I have asked a similar question before regarding trimming from both ends of the data entry, but this time I am after just trimming whitespace off the end. If anyone has previously answered to that one, then please bare with me as I will eventually assign points.
thanks a bunch
John
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2003 05:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2003 05:50 AM
01-15-2003 05:50 AM
Re: trimming a large file
Since whitespace can be spaces and/or tabs:
# sed -e 's/[ \t]*$//' filename
...note: Actually type a TAB character instead of the \t since many 'sed's will not honor it.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2003 05:50 AM
01-15-2003 05:50 AM
Re: trimming a large file
# aligns all text flush left
sed 's/^[ \t]*//'
# delete trailing whitespace (spaces, tabs) from end of each line
sed 's/[ \t]*$//'
# delete BOTH leading and trailing whitespace from each line
sed 's/^[ \t]*//;s/[ \t]*$//'
Does that help?
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2003 05:56 AM
01-15-2003 05:56 AM
Re: trimming a large file
Pete, I will gladly have your babies! superb!
thanks again
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2003 06:05 AM
01-15-2003 06:05 AM
Re: trimming a large file
Chuck J
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2003 06:08 AM
01-15-2003 06:08 AM
Re: trimming a large file
And of course we can use another regexp to remove just trailing "whitespace"
sed "s/\([[:space:]]*$\)//"
so many ways to wok the cat
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2003 06:12 AM
01-15-2003 06:12 AM
Re: trimming a large file
perl -ple '{s/\s*$//}' filename
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2003 03:21 PM
01-15-2003 03:21 PM
Re: trimming a large file
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2003 03:22 PM
01-15-2003 03:22 PM
Re: trimming a large file
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2003 03:20 AM
01-16-2003 03:20 AM
Re: trimming a large file
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2003 04:40 AM
01-16-2003 04:40 AM
Re: trimming a large file
That is a great list of "compiled" sed statements! Thanks!
BTW, My ex-wife thinks I'm the World Bank - ready to give money to those that don't need it or can't pay it back. As for my kids, the two oldest (still in high school) have to work part time for their car and insurance.
live free or die
harry