سؤال

a="abc-ABC-3.2-def"

For the above mentioned variable, I need to cut so that i get all the string before occurrence of number.

Output expected after cut is,

 abc-ABC- 

The number can be anything, Please help.

هل كانت مفيدة؟

المحلول

echo $a | awk '{print $1}' FS=[0-9]

نصائح أخرى

Using bash strings:

echo ${a%%[0-9]*}

%% means greedy pattern matching from the right, we match any digit (0-9) followed by some text (or nothing).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top