Hi,
I have been struggling with this problem on and off for quite some time, more recently fairly constantly.
I want a sed command (in a script) to gather image filenames from a directory and replace the instances of 'large' and 'small' in a html template document with the relevant images consecutively. The goal is to bash script although sometimes I am unsure whether I type [cmd=]sh 'script'[/cmd] at the shell or [cmd=]bash 'script'[/cmd] it makes a difference.
I have a directory (currently /tmp) where the images are as well as the script (egg.go). The template document (egg.one) resides currently at /root/egg.one. The errors I get don't seem to mean too much to me and I just looked for a listing of errors a bit and found none.
The consistent issue is that I can (sometimes) get the image file names to replace the 'large' and 'small' words but the script (I think) just continues to write over itself until the only replacement is the last image filename. Occasionally I get a situation where the first image filename replaces. Most often the 'small' replacement works better (don't know why).
Unless I miss my guess I am writing the sed wrong, which is pretty much the only thing I have been changing.
I think that I could use the instances of "table" in the template to control how I increment but I have been unsuccessful in getting that to work;
-large-
* the filenames are a list of DSCN0717.JPG like names although there are a few exceptions; like sDSCN0717.JPG
-small-
* the filenames are more different; DSCN0988.jpg and small.jpg
For the most part these names are just for testing but I realize that the names may in some way botch my script's function.
I hope someone can help with this, or at least point me to some listings of errors and their explanations.
Thanks
a5'
I have been struggling with this problem on and off for quite some time, more recently fairly constantly.
I want a sed command (in a script) to gather image filenames from a directory and replace the instances of 'large' and 'small' in a html template document with the relevant images consecutively. The goal is to bash script although sometimes I am unsure whether I type [cmd=]sh 'script'[/cmd] at the shell or [cmd=]bash 'script'[/cmd] it makes a difference.
I have a directory (currently /tmp) where the images are as well as the script (egg.go). The template document (egg.one) resides currently at /root/egg.one. The errors I get don't seem to mean too much to me and I just looked for a listing of errors a bit and found none.
The consistent issue is that I can (sometimes) get the image file names to replace the 'large' and 'small' words but the script (I think) just continues to write over itself until the only replacement is the last image filename. Occasionally I get a situation where the first image filename replaces. Most often the 'small' replacement works better (don't know why).
Unless I miss my guess I am writing the sed wrong, which is pretty much the only thing I have been changing.
Code:
sed s/large/$LIM/ /root/egg.one > gallery.html
I think that I could use the instances of "table" in the template to control how I increment but I have been unsuccessful in getting that to work;
Code:
sed /table,4/s/large/$LIM/ /root/egg.one > gallery.html
-large-
* the filenames are a list of DSCN0717.JPG like names although there are a few exceptions; like sDSCN0717.JPG
-small-
* the filenames are more different; DSCN0988.jpg and small.jpg
For the most part these names are just for testing but I realize that the names may in some way botch my script's function.
I hope someone can help with this, or at least point me to some listings of errors and their explanations.
Thanks
a5'
Code:
THE SCRIPT
#!/usr/local/bin/bash
S_IMAGE=*.jpg
L_IMAGE=*.JPG
for LIM in $L_IMAGE;do
sed s/large/$LIM/ /root/egg.one > /tmp/gallery.html
# lines commented out for simplcity.
#for SIM in $S_IMAGE;do
#sed s/small/$SIM/ /root/egg.one > /tmp/gallery.html
#done
done
Code:
THE TEMPLATE
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transistional//EN'>
<html>
<head>
<title> Gallery Page number</title>
</head>
<body>
<h1> Gallery Page 1 </h1>
<table width='80%' height='100%' border='1' cellspacing='10'
cellpadding='10>
<a href="large"><img
scr="small" align='center' alt="small">
<table width='80%' height='100%' border='1' cellspacing='10'
cellpadding='10'>
<a href="large"><img
src="small" align='center' alt="small">
<table width='80' height='100' border='1' cellspacing='10'
cellpadding='10'>
<a href="large"><img
src="small" align='center' alt="small">
</body>
</html>