The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 11-04-2008
msb65 msb65 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 89
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
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 On




All times are GMT -4. The time now is 01:39 PM.


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