![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Extract string between <> | rakeshou | Shell Programming and Scripting | 14 | 11-21-2007 10:10 AM |
| How to Extract string? | namrata5 | High Level Programming | 2 | 10-24-2007 12:17 AM |
| Extract digits at end of string | offirc | Shell Programming and Scripting | 6 | 11-20-2006 08:57 AM |
| Extract String | sehgalniraj | UNIX for Dummies Questions & Answers | 1 | 09-25-2006 09:35 AM |
| How to extract a portion of a string from the whole string | ds_sastry | UNIX for Dummies Questions & Answers | 2 | 09-29-2001 07:40 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Extract String
Hello. I would like to extract the word "PATTERN" from a file that occurs on mulitple lines:
{1:5TIROEKUDRSH0027000755}{2:O4351423051114PATTERN40130656410423N} Thank you. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
$ cat aa
{1:5TIROEKUDRSH0027000755}{2:O4351423051114PATTERN40130656410423N} $ cat aa|sed -e "s/PATTERN//g" {1:5TIROEKUDRSH0027000755}{2:O435142305111440130656410423N} |
|
#3
|
|||
|
|||
|
Thank you. Let me provide more detail. I would like to get the word "Pattern" plus the next 5 characters following:
In: {1:5TIROEKUDRSH0027000755}{2:O4351423051114PATTERN40130656410423N} Out: PATTERN40130 Thanks. |
|
#4
|
||||
|
||||
|
Quote:
In resonse to the second question: Code:
sed -n 's/.*\(PATTERN.....\).*/\1/' file |
|
#5
|
|||
|
|||
|
the best i can do so far....
$ cat aa {1:5TIROEKUDRSH0027000755}{2:O4351423051114PATTERN40130656410423N} {1:5TIROEKUDRSH0027000755}{2:O4351423051114PATTERN50130656410423N} {1:5TIROEKUDRSH0027000755}{2:O4351423051114PATTERN60130656410423N} $ while read all > do > expr substr "$all" 44 12 > done < aa PATTERN40130 PATTERN50130 PATTERN60130 |
|
#6
|
|||
|
|||
|
Thank you.
|
|||
| Google The UNIX and Linux Forums |