Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
google site



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-14-2009
Registered User
 

Join Date: Dec 2009
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Using CP in bash script

I've got something to this effect:


Code:
read -n1 -p "Continue? (y/n)"
if [[ $REPLY == [yY] ]]
        then printf "\n" &&
                cp -prv $WODI/* $OTHERDRIVE &&
                chown -R mail:mail $MAIL/$userdir &&
                echo -e "Files copied from '$WODI/' to '$OTHERDRIVE/' and chowned 'vmail:vmail':\n"
        else die "\nExiting..."
fi
if [[ ! -L $WODI ]]
        then read -n1 -p "Create symlink (ln -s $OTHERDRIVE $WODI)?? (y/n)" &&
                [[  $REPLY == [yY] ]] &&
                ln -sf $OTHERDRIVE $WODI
        else printf "\n"
fi
if [[ -L $WODI ]]
        then echo -e "\nSymlink '$OTHERDRIVE' created successfully:\n" &&
                ls --color -lA $LISTING | egrep $userdir
        else echo -e "\nSymlink '$OTHERDRIVE' does not exist.\n"
fi

This is a clip from a script I'm working on to move courier-imap mail directories (maildir format) to another drive, and then symlink the original location to the new.
I'm running into the issue on this line:

Code:
cp -prv $WODI/* $OTHERDRIVE

cp runs just fine with this command, but it omits all of my maildir folders (folders that being with a period, ie ."Trash") for some reason. Running cp (outside of the script) on the same directory will copy all directories.

Also, please tell me of any general scripting errors I may be committing, or anything that doesn't look right.

Thanks, guys!
Sponsored Links
  #2  
Old 12-14-2009
fpmurphy's Avatar
Moderator
 

Join Date: Dec 2003
Location: /dev/ph
Posts: 2,486
Thanks: 1
Thanked 39 Times in 38 Posts
You need to add another copy command to handle the dot files.

Code:
cp -prv $WODI/.[a-zA-Z0-9]* $OTHERDRIVE

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl cgi script to call bash script? pleonard Shell Programming and Scripting 0 06-02-2009 01:57 PM
Bash script: issue changing directories in script Breakology Shell Programming and Scripting 5 05-26-2009 08:47 AM
how to make your bash script run on a machine with csh and bash npatwardhan Shell Programming and Scripting 3 11-19-2008 03:17 AM
passing variable from bash to perl from bash script arsidh Shell Programming and Scripting 10 06-04-2008 12:25 PM
Why generate "ash and bash" different output for same bash script? s. murat Shell Programming and Scripting 0 05-26-2008 07:19 AM



All times are GMT -4. The time now is 02:35 AM.