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
remove spaces btw tjmannonline UNIX for Dummies Questions & Answers 7 05-26-2008 02:35 AM
sh, ksh: command to remove front spaces from a string? pseudocoder Shell Programming and Scripting 3 09-22-2007 07:57 AM
How to remove trailing spaces mahek_bedi UNIX for Dummies Questions & Answers 2 08-10-2007 07:21 AM
remove blank spaces in a string spandu Shell Programming and Scripting 2 03-02-2006 02:08 AM
Variable has spaces around the string, need to remove them mikey20 Shell Programming and Scripting 4 10-13-2005 08:09 PM

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 06-02-2005
radhika radhika is offline
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.
  #2 (permalink)  
Old 06-02-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
infile=`echo "$infilename" | sed 's/ //g'`
  #3 (permalink)  
Old 06-02-2005
radhika radhika is offline
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.
  #4 (permalink)  
Old 06-02-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
check out the FAQ and also this thread
  #5 (permalink)  
Old 06-02-2005
BCarlson BCarlson is offline
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.
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 08:16 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