The UNIX and Linux Forums  


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



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

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #8 (permalink)  
Old 11-22-2009
danmero danmero is offline Forum Advisor  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,519

Code:
# STRING="Hello World! word1 word2 AND another word3 at the END.";
# FILTERED=${STRING// word[1-9]/};
# echo "$FILTERED"
Hello World! AND another at the END.

Works on bash
  #9 (permalink)  
Old 11-22-2009
Registered User
 

Join Date: Nov 2009
Posts: 5
Ok thanks.


Code:
str="It's cold, very cold"
pattern=${str/cold/hot}
echo $pattern

Is possible to replace the second "cold" by "hot" and keep the first "cold" with extended globbing ?
  #10 (permalink)  
Old 11-23-2009
Registered User
 

Join Date: Nov 2008
Location: Amsterdam
Posts: 1,258

Code:
echo ${str%cold}hot

But I suspect that does not satisfy your question
  #11 (permalink)  
Old 11-23-2009
Registered User
 

Join Date: Nov 2009
Posts: 5
Quote:
Originally Posted by Scrutinizer View Post
Code:
echo ${str%cold}hot

But I suspect that does not satisfy your question
It do, thanks.
The % char is used to read from the end of str ?
Sponsored Links
Reply

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk - replace number of string length from search and replace for a serialized array otrotipo Shell Programming and Scripting 1 07-10-2009 01:04 PM
Search, replace string in file1 with string from (lookup table) file2? gstuart Shell Programming and Scripting 9 06-08-2009 07:11 AM
Search for a string and replace the searched string in the same position in samefile ganesh_248 UNIX for Dummies Questions & Answers 27 03-23-2009 12:35 AM
Search for a string and replace the searched string in the same position ganesh_248 Shell Programming and Scripting 15 02-09-2009 09:35 PM
Find the position of a string and replace with another string bab123 Shell Programming and Scripting 6 01-21-2009 04:14 AM



All times are GMT -4. The time now is 11:40 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