emily
1
Dear all,
I am using the awk 'split' command to get the particular value.
FILE=InputFile_009_0.txt
Temp=$(echo $FILE | awk '{split($FILE, a, "e_"); print a[2]}')
I would like to have the Temp take the value as : _009_0
any suggestions?
Thanks in advance,
emily
Hello emily,
You could try following command and let us know if this helps.
echo $FILE | awk '{match($0,/\_.*\_/);print substr($0,RSTART,RLENGTH+1)}'
Thanks,
R. Singh
1 Like
How about:
filenoext=${FILE%.*}
Temp=${filenoext#InputFile}
--
with awk:
echo "$FILE" | awk '{split($0, F, /InputFile|\./); print F[2]}'
or
echo "$FILE" | awk -F 'InputFile|[.]' '{print $2}'
1 Like
@Emily. What does this have to do with your original question? Please start a new thread for a new topic...
emily
6
Sorry, It has been moved to separate thread.
regards,
emily.