Results 1 to 3 of 3
I have a filename
file-name-here-1.2.3-i486-2.tar
I would like to know how to remove the last two fields leaving only:
file-name-here-1.2.3
I can use:
x=file-name-here-1.2.3-i486-2.tar
echo ${a%-*}
to remove the last ...
- 04-27-2010 #1Just Joined!
- Join Date
- Feb 2005
- Posts
- 14
[SOLVED] How to remove last two fields
I have a filename
file-name-here-1.2.3-i486-2.tar
I would like to know how to remove the last two fields leaving only:
file-name-here-1.2.3
I can use:
x=file-name-here-1.2.3-i486-2.tar
echo ${a%-*}
to remove the last field (after -) but how do i remove the last two in one fell swoop?
Thank you gurus
- 04-27-2010 #2Linux Newbie
- Join Date
- Sep 2004
- Location
- UK
- Posts
- 160
echo ${x%-*-*}
or
echo ${x%-i*}In a world without walls and fences, who needs Windows and Gates?
- 04-28-2010 #3Just Joined!
- Join Date
- Feb 2005
- Posts
- 14
Beautiful. Thanks a bunch.


