how to get only the first alphabet pattern from a input?
I have some files with below names:
xen-scripts-org-4.999.9-0.3.beta.20021004git.blahblah.x86_64 xx-yyyy-zzzz-4.999.9-0.3.beta.20021007git.8.amzn1.x86_64 I'd like use some command or a small script to get the first letters(not numbers) from those file names. output should look like: xen-scripts-org Please help. |
Is this what you want
Code:
echo xx-yyyy-zzzz-4.999.9-0.3.beta.20021007git.8.amzn1.x86_64|cut -d'-' -f1,2,3 |
hi chrism01,
but if the input is something like this "xx-yyyy-4.999.9-0.3.beta.20021007git.8.amzn1.x86_64" i won't be getting the desired output ..right? I need to ignore the numbers from the input and get the first name. Thanks for your reply. |
That's what it does; you get the leading xx-yyyy-zzzz; just try it.
If unless you wanted something else, please show a before and after example to clarify. |
Could you post examples of input and required output.
|
Quote:
If i use your command.. it gives the following out put... [user@mc ~]$ echo xx-yyyy-4.999.9-0.3.beta.20021007git.8.amzn1.x86_64|cut -d'-' -f1,2,3 xx-yyyy-4.999.9 Which is wrong. |
If input is xx-4.999.9-0.3.beta.20021007git.8.amzn1.x86_64 should get xx
& xx-4.99 should get xx & abcd-2.555.6666.8885 should get abcd & xx-yyyyy-zzzz-wwww-20021007git.8 should get xx-yyyyy-zzzz-wwww |
Ok, so a variable num of 'fields' before the 4.999 etc.
IF the 4.99 is a constant ie where you want to grab the prefix Code:
echo xx-yyyy-zzzz-4.999.9-0.3.beta.20021007git.8.amzn1.x86_64|sed -e s/-4.*// Edit: so had that open while you posted above. Here's the amended sed Code:
sed -e s/-[0-9].*// |
thanks Chris.
|
All times are GMT -5. The time now is 01:43 AM. |