The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
remove spaces btw tjmannonline UNIX for Dummies Questions & Answers 7 05-25-2008 11:35 PM
sh, ksh: command to remove front spaces from a string? pseudocoder Shell Programming and Scripting 3 09-22-2007 04:57 AM
How to remove trailing spaces mahek_bedi UNIX for Dummies Questions & Answers 2 08-10-2007 04:21 AM
remove blank spaces in a string spandu Shell Programming and Scripting 2 03-01-2006 11:08 PM
Variable has spaces around the string, need to remove them mikey20 Shell Programming and Scripting 4 10-13-2005 05:09 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-02-2005
Registered User
 

Join Date: Apr 2005
Posts: 51
how to remove spaces in a string using sed.

Hello,

I have the following to remove spaces from beginning and end of a string.
infile=`echo "$infilename" | sed 's/^ *//;s/ *$//`

How do I modify the above code to remove spaces from beginning, end and in the middle of the string also.

ex:
Shell Programming is fun
Result should be:
ShellProgrammingisfun


ThankYou,
Radhika.
Reply With Quote
Forum Sponsor
  #2  
Old 06-02-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
infile=`echo "$infilename" | sed 's/ //g'`
Reply With Quote
  #3  
Old 06-02-2005
Registered User
 

Join Date: Apr 2005
Posts: 51
I have one more question- what is a good book for awk, sed, grep, kshell scripting for beginners like me.

ThankYou! for your prompt replies.

Appreciate it!
Radhika.
Reply With Quote
  #4  
Old 06-02-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
check out the FAQ and also this thread
Reply With Quote
  #5  
Old 06-02-2005
Registered User
 

Join Date: May 2005
Posts: 48
Smile Unix Book

A book that I've had success with is: UNIX Shells, by Ellie Quigley. It has some typos in it but it's rather good.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:51 AM.


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