Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extracting certain characters 1

Status
Not open for further replies.

macca007

Programmer
May 1, 2004
86
GB
Hi all am fairly new to unix, and wat i have is certain file with the name 2342_dd2233_10.jpg

what i would like to do is extract the characters after the first _

so it would only show me dd2233

Could any of u's help me solve this

Cheers
 
Try...
[tt] echo 2342_dd2233_10.jpg | cut -d_ -f2[/tt]
 
shell-only alternative

FILE="2342_dd2233_10.jpg"
FILE=${FILE#*_}
FILE=${FILE%_*}
echo $FILE



Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
use sed
Code:
echo d_a34_b21.jpg | sed 's/[^_]*_//'
[code]


seeking a job as java-programmer in Berlin: [URL unfurl="true"]http://home.arcor.de/hirnstrom/bewerbung[/URL]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top