Hi All,
I am trying to extract only characters from a string value eg:
abcdedg1234.cnf
How can I extract only characters
abcdedg
and assign to a variable.
Please help.
Thanks
Hi All,
I am trying to extract only characters from a string value eg:
abcdedg1234.cnf
How can I extract only characters
abcdedg
and assign to a variable.
Please help.
Thanks
Hello abhi_123,
Please use CODE TAGS as per forum rules for your sample Input_file and sample output_file, following may help you in same.
val="abcdedg1234.cnf"
echo "$val" | awk '{match($0,/[a-zA-Z]+/);print substr($0,RSTART,RLENGTH)}'
To keep above into a variable and print it's value do following.
var=$(echo "$val" | awk '{match($0,/[a-zA-Z]+/);print substr($0,RSTART,RLENGTH)}')
echo "$var"
abcdedg
Thanks,
R. Singh
Try:
var=abcdedg1234.cnf
echo "${var%%[![:alpha:]]*}"