![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| last char from a string | broli | Shell Programming and Scripting | 6 | 12-07-2007 08:02 PM |
| replacing char with string | phani_sree | High Level Programming | 1 | 11-20-2006 08:57 AM |
| string of 7 char length always... | thanuman | UNIX for Dummies Questions & Answers | 3 | 04-12-2005 01:51 PM |
| Number of specific char in a string. | gio123bg | Shell Programming and Scripting | 7 | 12-19-2003 02:27 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
how to get number char from a string
for example:
i hav a string like : /rmsprd/arch01/rmsprd/rmsprdarch72736.log how I can extract my_num=72736? I know I can echo "/rmsprd/arch01/rmsprd/rmsprdarch72736.log" | tr "/" " " | awk '{ print $4 }' to get rmsprdarch72736.log |
|
|||||
|
If you are using ksh93 you do not need to invoke external utilities like cut or sed. The following will work Code:
$ str="/rmsprd/arch01/rmsprd/rmsprdarch72736.log"
$ print $str
/rmsprd/arch01/rmsprd/rmsprdarch72736.log
$ print ${str/*([[:print:]])({5}(\d)).log/\2}
72736
$
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|