Extract part of file name using KornShell
-
24-10-2019 - |
Question
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?
Solution
$ file=xxdatafile_20110120123030_12342.dat
$ echo ${file%%_*}
xxdatafile
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow