On Thursday 08 August 2002 08:59, Nick Lindsell said:
 > At 14:34 08/08/2002 +0200, you wrote:
 > > "File_21_05082002" and i would like to
 > > extract "21" from this.
 > >How can i do it with 'sed'?
 >
 > No need for sed, cut is simpler:-
 > $extract= echo "File_21_05082002"|cut -c 6-7

Cut is easier for this problem but I'd modify it one bit....
$extract= `echo "File_21_05082002"|cut -d_ -f2`

This assumes (*cough*) that you want the value between the two "_" characters.

To answer your original question.....  In sed:
$extract=`echo $Fname | sed -e "s/^File_//" -e "s/_[0-9]*$//"`

Should come very close to what you wanted (I think...)



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to