Hello,
We have wrote shell script for multiple file name search pattern.
file format: <numner>_<20180809>.txt
starting with single number and ending with 8 digits number
Command:
awk -v string="12_1234" -v serch="^[0-9]+_+[0-9][0-9][0-9][0-9]$" "BEGIN{ if (string ~/serch$/) print string }"
If sting matches then return value.
panyam
June 14, 2018, 1:51am
2
Hi Rama,
Its not clear on what you are looking for.
Can you share sample input and output you are expecting.
RudiC
June 14, 2018, 2:49am
3
Try
awk -v string="12_1234" -v serch="^[0-9]+_+[0-9][0-9][0-9][0-9]$" "BEGIN{ if (match (string,serch)) print string }"
12_1234
Try this adaptation to your command in post #1:
awk -v string="12_1234" -v serch="^[0-9]+_+[0-9][0-9][0-9][0-9]$" "BEGIN{ if (string ~ serch) print string }"
2 Likes
Hello Rudi,
Thank you very much,it's working as expected.