|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I am trying to strip the suffix 'jpg' from a list of images. I keep
getting this error. ../writeimage: line 23: and this is what you catch.jpg: command not found ../writeimage: line 23: dave-damon-2006-3.jpg: command not found ../writeimage: line 23: Double exposure.jpg: command not found Here is a snippet containing the error producing code. for filename in *.jpg; ##list images in directory do if [ -f "$filename" ] then CAPTION=basename "$filename" .jpg imageline=" <td align=\"center\"> <p style=\"margin-top: 0; margin-bottom: 0\"> <img border=\"0\" src=\"$filename\"></a></p> <p style=\"margin-top: 0; margin-bottom: 0\">"$CAPTION"</p> </td>" This is a maintance tool for me. I run it on my debian based machine. TIA Dave -- A little rum in the morning coffee. Just to clear the cobwebs, ya know. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Dave Kelly wrote:
> I am trying to strip the suffix 'jpg' from a list of images. I keep > getting this error. > > ./writeimage: line 23: and this is what you catch.jpg: command not found > ./writeimage: line 23: dave-damon-2006-3.jpg: command not found > ./writeimage: line 23: Double exposure.jpg: command not found > > Here is a snippet containing the error producing code. > > for filename in *.jpg; ##list images in directory > > do > if [ -f "$filename" ] > then > > CAPTION=basename "$filename" .jpg CAPTION=$( basename "$filename" .jpg ) or using shell builtins instead of costly external processes... CAPTION=${filename%.jpg} Janis > > imageline=" > <td align=\"center\"> <p style=\"margin-top: 0; margin-bottom: 0\"> <img > border=\"0\" src=\"$filename\"></a></p> <p style=\"margin-top: 0; > margin-bottom: 0\">"$CAPTION"</p> </td>" > > This is a maintance tool for me. I run it on my debian based machine. > > TIA > Dave > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Janis Papanagnou wrote:
> CAPTION=$( basename "$filename" .jpg ) > > or using shell builtins instead of costly external processes... > > CAPTION=${filename%.jpg} > > > Janis Worked like a charm. Thanks. Where would I go to read/learn about some of this stuff. A google search did not turn up any interesting leads. Is there a better place than 'info coreutilities'? Does this cover builtins? Thanks again. Dave -- A little rum in the morning coffee. Just to clear the cobwebs, ya know. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Dave Kelly wrote:
> Janis Papanagnou wrote: > >> CAPTION=$( basename "$filename" .jpg ) >> >> or using shell builtins instead of costly external processes... >> >> CAPTION=${filename%.jpg} >> >> >> Janis > > > Worked like a charm. Thanks. > Where would I go to read/learn about some of this stuff. A google search > did not turn up any interesting leads. > Is there a better place than 'info coreutilities'? Does this cover > builtins? The builtins depend on the used shell, for Kornshell for example you can find the information in the manpage online http://www.cs.princeton.edu/~jlk/kor...doc/man93.html or for bash with man bash. Though careful about portability; even most modern shells have a large common subset you may occasionally want to restrict to the POSIX subset. (The above ${...%...} is POSIX.) Surely the man pages are a good source to get an overview of the shell features. Janis > > Thanks again. > Dave > > |
|
![]() |
| Outils de la discussion | |
|
|