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 > Operating Systems > Linux
.
google unix.com



Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions 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
Remove spaces from columns jacks Shell Programming and Scripting 2 01-18-2008 10:08 AM
How to remove trailing spaces mahek_bedi UNIX for Dummies Questions & Answers 2 08-10-2007 07:21 AM
Removing empty spaces and adding commas jazz High Level Programming 4 11-13-2006 09:54 AM
how to remove spaces in a string using sed. radhika Shell Programming and Scripting 4 06-02-2005 03:00 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-26-2008
anushree.a anushree.a is offline
Registered User
  
 

Join Date: May 2008
Posts: 87
Talking How do i remove commas(,) & spaces

Hey guys,
I am very much new to shell scripts. So you ppl may feel that i am asking stupid question here.
1. I am using command line argument as an input variable. The user gets this value in his mail from client which has commas n spaces (Eg. 12,34,56,789) and the scripts input should not contain any commas, spaces dashes etc... So to Normalise it i hv used following thing

sh 123.sh 12,34,56,789
#12,34,56,789 is jst an example of input i.e. command line argument.
echo "$1" | perl -pi -e "s/,//g;"

Now the problem is I want to take its output (i.e output of echo "$1" | perl -pi -e "s/,//g;" ) as input for next line of script. For this I tried following thing

echo "$1" | perl -pi -e "s/,//g;" | $i

But its not working... what do i do?
  #2 (permalink)  
Old 05-26-2008
jaduks's Avatar
jaduks jaduks is offline
Registered User
  
 

Join Date: Aug 2007
Location: Assam,India
Posts: 166
Code:
echo $1 | sed 's/,//g'
should work.

And you can assign that like this

Code:
S=`echo $1 | sed 's/,//g'`
Hope it answers your query.

//Jadu
  #3 (permalink)  
Old 05-26-2008
anushree.a anushree.a is offline
Registered User
  
 

Join Date: May 2008
Posts: 87
Hey Thanx for the quick reply
The line written by me in script (i.e echo "$1" | perl -pi -e "s/,//g;") even that is working... but what i want to do is, i want to take the output of this line in a variable... So that i can use it further.. Do u kno how do i do it?
  #4 (permalink)  
Old 05-26-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
This has been already answered by jaduks.. Check the S variable value, in jadu's post.
  #5 (permalink)  
Old 05-26-2008
siba.s.nayak siba.s.nayak is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 164
var1=`echo $1 | tr "," " "`
If $1 = 1,2,3
Then var1 will contain 1 2 3.

Thanks & Regards,
Siba


Quote:
Originally Posted by anushree.a View Post
Hey Thanx for the quick reply
The line written by me in script (i.e echo "$1" | perl -pi -e "s/,//g;") even that is working... but what i want to do is, i want to take the output of this line in a variable... So that i can use it further.. Do u kno how do i do it?
  #6 (permalink)  
Old 05-26-2008
anushree.a anushree.a is offline
Registered User
  
 

Join Date: May 2008
Posts: 87
Hey thanx a ton Jaduks, nua7 & Siba... finally it worked :-) I m very happy...
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:44 PM.


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