Results 1 to 4 of 4
I'm new to shell scripting and have a problem with a script. The problem is with this statement:
cp -rp "$DEVPATH/httpdocs/[!.]*" "$LIVEPATH/httpdocs"
The console puts out
cp: cannot stat `/var/www/vhosts/q2.com/httpdocs/[!.]*': ...
- 08-01-2007 #1Just Joined!
- Join Date
- Aug 2007
- Posts
- 3
cp $path/[!.]* doesn't work
I'm new to shell scripting and have a problem with a script. The problem is with this statement:
cp -rp "$DEVPATH/httpdocs/[!.]*" "$LIVEPATH/httpdocs"
The console puts out
cp: cannot stat `/var/www/vhosts/q2.com/httpdocs/[!.]*': No such file or directory
If I manually type that line at the shell prompt it works fine.
Code:#!/bin/bash LIVEPATH="/var/www/vhosts/qTEST.com" DEVPATH="/var/www/vhosts/q2.com" clear echo -ne "Have you updated all the database tables and set the SITE constant\nto 'live'? (yes/no) " read READY if [ "$READY" = "yes" ]; then alias cp='cp' # override cp-I alias rm -rf "$LIVEPATH/httpdocs.bak" cp -R "$LIVEPATH/httpdocs" "$LIVEPATH/httpdocs.bak" # [!.] excludes files starting with a ., specifically htaccess/htpasswd cp -rp "$DEVPATH/httpdocs/[!.]*" "$LIVEPATH/httpdocs" chown -R jbronec "$LIVEPATH/httpdocs" echo -e "\nThe dev files have been copied to live.\nMake sure you rebuild the homepage cache and change the SITE constant\non dev to 'dev'" else echo -e "\nYou need to update the database tables and SITE constant first." fi
- 08-02-2007 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Hi,
cp don't copy files with names started with a dot (hidden files).
Try this (without double quotes):
instead of:Code:cp -rp $DEVPATH/httpdocs/* $LIVEPATH/httpdocs
To copy all (hidden and regular) files you can do this:Code:cp -rp "$DEVPATH/httpdocs/[!.]*" "$LIVEPATH/httpdocs"
To copy only hidden files:Code:cp -rp $DEVPATH/httpdocs/ $LIVEPATH/
RegardsCode:cp -rp $DEVPATH/httpdocs/.[a-zA-Z0-9]* $LIVEPATH/
- 08-02-2007 #3
-a, the archive option I believe is synonymous with -rp. I use it frequently
Err correction, it's the same as -dpR
- 08-03-2007 #4Just Joined!
- Join Date
- Aug 2007
- Posts
- 3
Actually, the quotes were the problem. I removed them and it works fine. Thanks.


Reply With Quote