|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Extract a string from another string in UNIX
I have a string
string="Please have a nice day and sleep well Replace_12123_31233_32134_12342 Good day" How do i replace "Replace_12123_31233_32134_1234" in the above string.?? Please help. Regards, Qwerty |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
bash/ksh93: Code:
$ string="Please have a nice day and sleep well Replace_12123_31233_32134_12342 Good day"
$ string=${string//Replace_12123_31233_32134_12342/REPLACED}
$ echo $string
Please have a nice day and sleep well REPLACED Good day |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
extract string from another string
i do not require to replace that with "Replaced". i want to take out that string - "Replace_12123_31233_32134_12342" and do certain operations with it... this might be a different string everytime... but the position of the string wouldnt change..
|
|
#4
|
||||
|
||||
|
Quote:
Please elaborate on this aspect. At what position will "this" string occur in the bigger string? Does "this" string terminate with a space/end-of-bigger-string? or does "this" string have a fixed length? |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Extract a string between 2 ref string from a file | jao_madn | Shell Programming and Scripting | 4 | 05-15-2012 11:08 AM |
| to extract string from main string and string comparison | vivek d r | Shell Programming and Scripting | 2 | 11-16-2011 07:17 AM |
| extract digits from a string in unix | sonu_pal | Shell Programming and Scripting | 3 | 08-03-2010 05:30 AM |
| Search for string in a file and extract another string to a variable | daikeyang | Shell Programming and Scripting | 6 | 03-20-2009 08:45 PM |
| extract a sub string from a main string | madhu.it | Shell Programming and Scripting | 5 | 10-04-2008 02:22 AM |
|
|