--- On Thu, 12/25/08, Erez D <erez0...@gmail.com> wrote:

> From: Erez D <erez0...@gmail.com>
> Subject: bash q -substitution
> To: "linux-il" <linux-il@cs.huji.ac.il>
> Date: Thursday, December 25, 2008, 11:20 AM
> hi
> 
> i need to convert a string using bash
> 
> 
> input_000.txt -> i need to extract the 000
For this exact pattern you can do
echo ${i:6:3}
         6 - offset
         3 - length

Why do you want it in one command ?

Valery

> 
> using sed i would do : sed
> 's/^.*_//ls/\.txt$//'
> 
> using bash i can do in two lines:
> (assuming input-string is stored in variable 'i' )
> 
> x=${i##*_}
> result=${x%%.txt}
> 
> 
> can it be done in bash in one line ? (i.e. can i
> concatenate substitutions
> ?)
> 
> 
> thanks,
> erez.


      

=================================================================
To unsubscribe, send mail to linux-il-requ...@cs.huji.ac.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-requ...@cs.huji.ac.il

Reply via email to