Odd result from cp -R foo/.* bar


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Odd result from cp -R foo/.* bar
# 1  
Old 06-02-2010
Odd result from cp -R foo/.* bar

I'm not all that much of a newbie but I've not encountered this before. Happens both in Cygwin and in Mac OS X (Darwin):


Code:
cp -R /path/to/foo/.* /path/to/bar

(where directory 'bar' exists)

... seems to copy not only the contents of directory 'foo', but also other directories that are "siblings" of foo!

On the other hand,

Code:
cp -R /path/to/foo/* /path/to/bar

... works the way I'd expect -- copying files and subdirectories of foo into bar. (But I want the '.' files too.)

Can someone clue me on what's happening?
# 2  
Old 06-02-2010
What do you normally find in a directory?
Code:
ra:/home/vbe $  ls -al
total 18
drwxrwxr-x   6 vbe        bin             96 Jun  2 16:21 .
drwxrwxrwx  25 vbe        seinf         5120 Jun  2 15:05 ..
etc...

You see the directory ..? when you type cd .., where do you find yourself? and what do you see in the now current directory?

Last edited by vbe; 06-02-2010 at 11:30 AM..
# 3  
Old 06-02-2010
Oh, my!
Come to think of it, I've seen commands that have flags for specifically ignoring '.' and '..', but cp doesn't seem to have such an option. Is there a way to "wildcard" my dot-directories to cp, or do I need to cook up a 'find' command to do this?

(What I'm really trying to do is set up a default home directory by copying from a model directory. Perhaps I should just copy and rename the model directory.)
# 4  
Old 06-02-2010
in that case, I put in a directory called default_home which contains all the files I want: .profile, .kshrc, .login, .exrc, .cshrc and copy using cp -p <default_home>/.[ceklp]* <newhome>/.
then I if required, change the ownership...
Like that I keep the original timestamp and can compare if files have been modified/customized...

All the best
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Having trouble understanding this command: >foo<bar bc

Sometimes it works for me and sometimes I get this error: syntax error on line 1, teletype Basically I've got no idea whats going on, especially at the end of the command: bc Any help is appreciated (1 Reply)
Discussion started by: phunkypants
1 Replies

2. UNIX for Dummies Questions & Answers

UNIX newbie with a really odd result!

I am relatively new to UNIX and am having some really weird results with redirecting output. I will start at the beginning. I have a file with consists of a list of a chemical name followed by a tab and then a string of characters known as a SMILE string in this format PS_1 C=C PS_2 ... (4 Replies)
Discussion started by: Osito22es
4 Replies

3. Shell Programming and Scripting

SED: Extracting text between first occurance of foo in front of bar

Suppose I have a text file that contains the tags <foo> and <bar>. The text file can have unlimted occurances of <foo> and <bar> and looks somthing like this: <foo> Some Text <foo> Some Text <bar> Some Text <foo> Some (1 Reply)
Discussion started by: ArterialTool
1 Replies

4. Shell Programming and Scripting

using /etc/foo.config in shell script

I'm very very new to shell scripting (about 4 hours) i've google'd till i can't google no more is it possible to have store values in a config file .e.g /etc/foo.conf data=/home/ mount=/dev/sda1 size=1GB and access these values from a shell script but also be able to use... (3 Replies)
Discussion started by: xpd259
3 Replies

5. Shell Programming and Scripting

Replace space and vertical bar with verical bar

I am trying to get sed, tr or awk to search a file that contains records with fields delimited by the vertical bar | and replace the occurrences in the records where the vertical bar is preceded by a space " |" with a vertical bar. Sample data record zelli |||59 Stonewall Dr ||W Barnstable |MA... (2 Replies)
Discussion started by: clintrpeterson
2 Replies

6. Shell Programming and Scripting

if [ -z echo foo | egrep -e 'regexp' != '' ] -> dont work

Hallo, I need to test a String (a special ip number-string). So I want to run that: ipadress=172.0.0.0 # for debugging: echo $ipadress | egrep -e '172\.?\.??\.??$' # the test that doesnt work if test -z `echo $ipadress | egrep -e '172\.?\.??\.??$'` != "" then echo "match" else... (1 Reply)
Discussion started by: wiseguy
1 Replies

7. Shell Programming and Scripting

Regex & grep-foo

I need a way to grep -v a list of times/date from the output of postqueue -p that are a few hours old, in order to remove them with postsuper -d. Right now I have a script that is deleting the previous day of messages left in the queue, which runs once each day. I want to clean up the job and... (1 Reply)
Discussion started by: DoneWithM$
1 Replies

8. UNIX for Dummies Questions & Answers

foo

if ; then echo Its Cold for $sid at $c_dst $jobroot/scripts/abc.sh $sid COLD $c_dst elif ; then echo Its Hot for $sid at $h_dst $jobroot/scripts/abc.sh $sid HOT $h_dst else echo No backup for $sid today wat does foo do ?? (2 Replies)
Discussion started by: bn_unx
2 Replies

9. Shell Programming and Scripting

Find directories not containing foo, and copy foo to them

Hello all, I have a situation where I have a web root directory with a few thousand users spread out into 100 subdirectories in a 00/firstname.lastname, 01/firstname.lastname, etc. hierarchy. I suddenly need to make sure that each of these user directories contains a default index.html file... (6 Replies)
Discussion started by: dkaplowitz
6 Replies
Login or Register to Ask a Question