Re: bash q -substitution

2008-12-30 Thread Erez D
On Tue, Dec 30, 2008 at 8:01 PM, Oleg Goldshmidt wrote: > "Erez D" writes: > > > Frankly, the exact requirements were not clear from your post (it is > > a > > coincidence that the solution I offered works for the revised > > requirements as well). > > > > btw, it didn't > >

Re: bash q -substitution

2008-12-30 Thread Oleg Goldshmidt
"Erez D" writes: > Frankly, the exact requirements were not clear from your post (it is > a > coincidence that the solution I offered works for the revised > requirements as well). > > btw, it didn't This only means that I don't understand the requirements. Cutting and pastin

Re: bash q -substitution

2008-12-30 Thread Erez D
On Tue, Dec 30, 2008 at 6:49 PM, Oleg Goldshmidt wrote: > "Erez D" writes: > > > this is a solution speceific to the .txt being preceided by the 000. > > (it will not work on path/input_000_xyz.txt). > > Why not? "basename ${foo/*input_/} _xyz.txt" will do it. > > Frankly, the exact requirements

Re: bash q -substitution

2008-12-30 Thread Oleg Goldshmidt
"Erez D" writes: > this is a solution speceific to the .txt being preceided by the 000. > (it will not work on path/input_000_xyz.txt). Why not? "basename ${foo/*input_/} _xyz.txt" will do it. Frankly, the exact requirements were not clear from your post (it is a coincidence that the solution I

Re: bash q -substitution

2008-12-28 Thread Ehud Karni
On Sun, 28 Dec 2008 13:21:59 Erez D wrote: > > On Sun, Dec 28, 2008 at 12:00 AM, Oleg Goldshmidt wrote: > > > >> > > >> $ basename ${foo/*input_/} .txt > > >> > > this is a solution speceific to the .txt being preceided by the 000. > (it will not work on path/input_000_xyz.txt). > > i just wanted t

Re: bash q -substitution

2008-12-28 Thread Erez D
On Sun, Dec 28, 2008 at 12:00 AM, Oleg Goldshmidt wrote: > On Sat, Dec 27, 2008 at 10:47 PM, Erez D wrote: > > > > > > On Fri, Dec 26, 2008 at 11:15 PM, Oleg Goldshmidt > > wrote: > >> > >> Well, if you insist, assuming that all the files have > >> "input_" in the beginning, you can use > >> ${p

Re: bash q -substitution

2008-12-27 Thread Oleg Goldshmidt
On Sat, Dec 27, 2008 at 10:47 PM, Erez D wrote: > > > On Fri, Dec 26, 2008 at 11:15 PM, Oleg Goldshmidt > wrote: >> >> Well, if you insist, assuming that all the files have >> "input_" in the beginning, you can use >> ${parameter/pattern/string} substitution, e.g., for string $foo use >> >> $ bas

Re: bash q -substitution

2008-12-27 Thread Erez D
On Fri, Dec 26, 2008 at 11:15 PM, Oleg Goldshmidt wrote: > On Thu, Dec 25, 2008 at 2:08 PM, Erez D wrote: > > > The problem is that the file's path varies, so the offset changes. > > i could use basename for removing the path, however i could also use sed > > > > > > > > > >> > >> Why do yo

Re: bash q -substitution

2008-12-26 Thread Oleg Goldshmidt
On Thu, Dec 25, 2008 at 2:08 PM, Erez D wrote: > The problem is that the file's path varies, so the offset changes. > i could use basename for removing the path, however i could also use sed > > > > >> >> Why do you want it in one command ? > > i do not like to use temporary variables (or f

Re: bash q -substitution

2008-12-25 Thread Erez D
On Thu, Dec 25, 2008 at 12:49 PM, Valery Reznic wrote: > > > > --- On Thu, 12/25/08, Erez D wrote: > > > From: Erez D > > Subject: bash q -substitution > > To: "linux-il" > > Date: Thursday, December 25, 2008, 11:20 AM > > hi > > &g

Re: bash q -substitution

2008-12-25 Thread Valery Reznic
--- On Thu, 12/25/08, Erez D wrote: > From: Erez D > Subject: bash q -substitution > To: "linux-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

bash q -substitution

2008-12-25 Thread Erez D
hi i need to convert a string using bash input_000.txt -> i need to extract the 000 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. c