filling variable with ls

hello All,

Need some further help.

This will make my live easier. Instead of copy and pasting I think I can automate some website building.

when I do a ls from a directory I need the file names placed into a sentence.

it is going about wordts like:

word-AB-1234.jpg
zample-ZA-3452.jpg
etc etc

what I want is 2 variable's filled like

the first part text till the - and what start with the - and everything after that. Like:

VAR1=word
VAR2=-AB-1234.txt

this I want to place in another file with some text

the following script is working as it should be but I forgot that there where other thinks I had to look for. script below is removing the .jpg part because I was thinking that was enough but it isn't. I need something more complicated lke described above.

VAR2=.jpg
ls /share1 | cut -f1 -d '.'|
while read filename
do
echo "<a rel=\"[reference code: $filename]\" href=\"/images/album/birds/$filename/$filename$VAR2\">"
 
done > /root/sample.txt

Script wil look like the same only it needs te be working with 2 variable to get it working correctly.

who can help me further

regards Walter

for file in *.jpg
do
var1=${file%%-*}
var2=-${file#*-}
echo $var1
echo $var2
done

-Devaraj Takhellambam