954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Parsing a String in Ksh

I have a string that looks like this
LOCATION="/home/dev/V1.0_MODULENAME_yyyyMMdd_hhss.tar"
I would like to parse it such that i get the module name.
I tried a k shell script with following commands...
MODULE=${LOCATION:20:32}
MODULE=${LOCATION#*_}

First one doesnt compile saying the specified substitution is not a valid command
and the second one gives part of what is required.

Can someone suggest the best way to get the modulename from my string

bhavana
Newbie Poster
1 post since Mar 2006
Reputation Points: 10
Solved Threads: 0
 
echo $LOCATION | awk -F"_" '{print $2}'
jim mcnamara
Junior Poster
180 posts since May 2004
Reputation Points: 62
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You