On Thu, Aug 08, 2002 at 01:59:50PM +0100, Nick Lindsell wrote: > At 14:34 08/08/2002 +0200, you wrote: > > > I have a word which is :"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 simpler, but if the format is always word_digits_word, then cutting based on exact character count might not be best solution. You can also cut based on a delimiter. Try (in bash): extract=`echo "File_21_05082002"|cut -d _ -f 2` This cuts the 2nd field where the string is delimited by underscores. -- Ed Wilts, Mounds View, MN, USA mailto:[EMAIL PROTECTED] Member #1, Red Hat Community Ambassador Program -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list