![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| CUT command - cutting characters from end of string | JWilliams | AIX | 2 | 01-28-2008 09:12 AM |
| extract segment | mpang_ | Shell Programming and Scripting | 1 | 01-12-2007 01:33 AM |
| Segment Fault | zhshqzyc | High Level Programming | 9 | 04-07-2006 11:47 AM |
| cutting part of string | dhaval_khamar | Shell Programming and Scripting | 3 | 07-25-2005 10:18 AM |
| Cutting Up a String | lesstjm | Shell Programming and Scripting | 4 | 09-21-2004 11:40 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Cutting segment of a string
Hi,
I am using bash. My question concerns cutting out segments of a string. Given the following filename: S2002254132542.L1A_MLAC.x.hdf I have been able to successfully separate the string at the periods (.): $ L1A_FILE=S2002254132542.L1A_MLAC.x.hdf $ BASE=$(echo $L1A_FILE | awk -F. '{ print $1 }') $ SUFFIX=$(echo $L1A_FILE | awk -F. '{ print $2 }') $ echo $BASE S2002254132542 $ echo $SUFFIX L1A_MLAC I would now like to cut the variable $SUFFIX so that I get only "MLAC". I have a feeling I could just add a pipe to a cut command, but there is a complication. The problem is that I will also have file names like: S2002254132542.L1A_LAC.x.hdf where the suffix will be L1A_LAC (note the missing M). Therefore although the cut will always start at the same number, it will not cut TO the same number. Rather I would just like to tell it to start cutting $SUFFIX and cut to the end of the string. - How do you tell cut to start at a specific number element in a string and cut until it reaches the end? Mike |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|