The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Of bash and whitespace... lev_lafayette Shell Programming and Scripting 2 04-13-2008 08:44 PM
Delete whitespace truck7758 Shell Programming and Scripting 12 12-05-2007 12:00 PM
trim whitespace? msteudel Shell Programming and Scripting 4 07-07-2005 07:57 PM
remove whitespace and test bensky Shell Programming and Scripting 4 09-25-2003 08:02 AM
Removing whitespace from files kevin80 Shell Programming and Scripting 10 06-10-2003 10:55 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-06-2007
b.hamilton b.hamilton is offline
Registered User
  
 

Join Date: Oct 2007
Location: Manchester, UK
Posts: 5
sed : remove whitespace

I'm trying to remove the whitespace at the end of each line of a text file in ksh.

Im using

sed s/ $//g' file1.txt > file2.txt

It's not working. Any clues?
  #2 (permalink)  
Old 11-06-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,418
Code:
sed 's/ $//'  file1.txt > file2.txt # Remove the last space at eol
sed 's/ $//g' file1.txt > file2.txt # Remove all spaces at eol
  #3 (permalink)  
Old 11-06-2007
kahuna's Avatar
kahuna kahuna is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 149
Quote:
Originally Posted by aigles View Post
Code:
sed 's/ $//'  file1.txt > file2.txt # Remove the last space at eol
sed 's/ $//g' file1.txt > file2.txt # Remove all spaces at eol
I don't think that will work. You need
Code:
sed 's/ *$//' file1.txt > file2.txt
  #4 (permalink)  
Old 11-06-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,418
Oups!
Code:
sed 's/ $//'  file1.txt > file2.txt # Remove the last space at eol
sed 's/ *$//' file1.txt > file2.txt # Remove all spaces at eol
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0