The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Remove Trailing spaces after a delimiter kiran_418 UNIX for Dummies Questions & Answers 1 04-29-2008 11:19 AM
Trailing spaces chopped off - MF to Unix FTP. videsh77 UNIX for Advanced & Expert Users 13 08-14-2007 01:24 PM
Strip leading and trailing spaces only in a shell variable with embedded spaces jerardfjay Shell Programming and Scripting 6 03-07-2005 11:24 AM
Adding Trailing Spaces to a file 222001459 UNIX for Dummies Questions & Answers 1 11-04-2004 12:23 PM
Leading and Trailing Spaces sleepster Shell Programming and Scripting 7 10-29-2003 08:48 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 08-09-2007
Registered User
 

Join Date: Aug 2007
Posts: 6
How to remove trailing spaces

Hi,

I have a file like this

(ADD_MONTHS((Substr(Trim(BOTH FROM Translate(Maximum(closeDa
------------------------------------------------------------
2007-06-30 00:00:00

I have a requirement where i need just the date.

When i do: tail -1 filename|tr -s ""
my problem doesnot solve.I am getting leading spaces before the date.

I need an output like: 2007-06-30 00:00:00

Can anybody help me??

-- Mahek
Reply With Quote
Forum Sponsor
  #2  
Old 08-09-2007
Registered User
 

Join Date: Feb 2006
Location: Schenectady, NY
Posts: 130
To remove leading spaces, use

tail -1 filename | sed -e "s/^ \{1,\}//"

or to removed trailing spaces

tail -1 filename | sed -e "s/ \{1,\}$//"
Reply With Quote
  #3  
Old 08-10-2007
Registered User
 

Join Date: Jun 2006
Posts: 74
you can try these as well

leading spaces :

tail -1 file1| sed -e "s/^ *//"

trailing spaces :

tail -1 file1| sed -e "s/ *$//"
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0