Arun Antony
Arun Antony

Reputation: 593

Extract part of file name using KornShell

I have a file name, for example: xxdatafile_20110120123030_12342.dat. I want to extract "XXdatafile_" from the file name.

How do I do that using Ksh on Unix?

Upvotes: 0

Views: 1803

Answers (1)

kurumi
kurumi

Reputation: 25609

$ file=xxdatafile_20110120123030_12342.dat
$ echo ${file%%_*}
xxdatafile

Upvotes: 6

Related Questions