User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 422,928 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,414 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 390 | Replies: 3
Reply
Join Date: Mar 2008
Posts: 19
Reputation: sjgriffiths is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
sjgriffiths sjgriffiths is offline Offline
Newbie Poster

Script question

  #1  
May 21st, 2008
Hello

I have the following in a variable called TEST

echo $TEST
result : STEPHEN LTD

What i want to do is find out whether there are any spaces in my variable name, and if so do the following

STEPHEN%42LTD

bascially put a %42 where the space is....any ideas?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2007
Location: Ireland
Posts: 1,630
Reputation: DimaYasny will become famous soon enough DimaYasny will become famous soon enough 
Rep Power: 6
Solved Threads: 70
Featured Poster
DimaYasny DimaYasny is offline Offline
Posting Virtuoso

Re: Script question

  #2  
May 21st, 2008
sed 's/ /%42/g'
Real stupidity always beats Artificial Intelligence. (Terry Pratchett)

BA BizMg, MCSE, DCSE, Linux+, Network+
Reply With Quote  
Join Date: Mar 2008
Posts: 19
Reputation: sjgriffiths is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
sjgriffiths sjgriffiths is offline Offline
Newbie Poster

Re: Script question

  #3  
May 21st, 2008
Thanks for the response....sorry i wasnt clear.

I have spaces .... lets say 3, maybe 4

But i want to put different things within in the spaces. So the above would put %42 in every space
Reply With Quote  
Join Date: Jan 2007
Location: Ireland
Posts: 1,630
Reputation: DimaYasny will become famous soon enough DimaYasny will become famous soon enough 
Rep Power: 6
Solved Threads: 70
Featured Poster
DimaYasny DimaYasny is offline Offline
Posting Virtuoso

Re: Script question

  #4  
May 21st, 2008
well, you've got the way to go, do read the manpages for sed.
Real stupidity always beats Artificial Intelligence. (Terry Pratchett)

BA BizMg, MCSE, DCSE, Linux+, Network+
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 1:53 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC