![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| retrieved multiple lines on multiple places in a file | dala | Shell Programming and Scripting | 8 | 03-14-2008 12:28 PM |
| Find, Append, Move & Rename Multiple Files | Trapper | Shell Programming and Scripting | 5 | 08-30-2007 04:39 AM |
| move file | ust | Shell Programming and Scripting | 1 | 08-04-2005 12:01 AM |
| move from one IP to another >ystrdays file | maverick | Shell Programming and Scripting | 14 | 11-12-2003 03:44 AM |
| help move file | hassan2 | UNIX for Advanced & Expert Users | 1 | 04-23-2002 11:31 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Multiple stage file move?
Greetings all.
I need is a script that will move a file from one known dir to another, then grab another file from a different dir to replace it, and have absolutely zero clue how to do this. Here's what I am trying to do: A web client wants his site header image to change based on US holidays. So, a script would grab the default header jpg, move it to a different dir somewhere on the site, then grab a header that has, say, a Christmas theme, and move that into the dir where the default one was. Make sense? I could then make a cron job that exe's the script based on known holiday dates. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Your solution (you'll probably need to wrap some additional logic and error handling etc round this):
Code:
#!/bin/sh
THEMEDDIR=/export/home/httpd/themes
HTMLDIR=/export/home/httpd/htdocs
FILE=header.jpg
THEME=xmas
if [ -r $HTMLDIR/$FILE ]
then
cp -p $HTMLDIR/$FILE $THEMEDIR/${FILE}.default
cp $THEMEDIR/${FILE}.${THEME} $HTMLDIR/$FILE
fi
Code:
#!/bin/sh
HTMLDIR=/export/home/httpd/htdocs
FILE=header.jpg
if [ -r ${HTMLDIR}/${FILE}.$1 ]
then
rm -f ${HTMLDIR}/${FILE}
ln -s ${HTMLDIR}/${FILE}.$1 ${HTMLDIR}/${FILE}
else
echo "$1 version of $FILE not found!"
exit 1
fi
Where theme is something like 'xmas' or 'default' etc. Them just have a copy of the header.jpg file for each theme (eg header.jpg.xmas), including the plain one called header.jpg.default. Run this script to switch to whatever one you need. |
|
#3
|
|||
|
|||
|
Awesome, thanks a lot. I'll give it a try.
|
|||
| Google The UNIX and Linux Forums |