Click to See Complete Forum and Search --> : simple variable filename question


seanesean
06-09-2002, 03:41 PM
I am trying to learn some simple scripts and have a simple question. I can't figure out how to use variable filenames in place of the ones I have below. Would some1 be so kind as to show me how the below example could be turned into a script utilizing variables in place of filenames???

#!/bin/sh

cp /varlog/rpmpkgs /public_html/scripting.txt
#copy rpmpkgs file to a new file in public_html called scripting.txt

cat /tmp/break >> /public_html/scripting.txt
#append scripting.txt file with contents of /tmp/break

cat script.sh >> /public_html/scripting.txt
#append scripting.txt with contents of this #file

chmod 755 /public_html/scripting.txt
#change file permissions of scripting.txt to #rwxr-xr-x

scanez
06-09-2002, 04:04 PM
#!/bin/sh

FILE=/public_html/scripting.txt

cp /varlog/rpmpkgs $FILE #copy rpmpkgs file to a new file in public_html called scripting.txt

cat /tmp/break >> $FILE #append scripting.txt file with contents of /tmp/break

cat script.sh >> $FILE #append scripting.txt with contents of this #file

chmod 755 $FILE #change file permissions of scripting.txt to #rwxr-xr-x
variable_name=value

then to access, $variable_name