Operating System - HP-UX
1834827 Members
2573 Online
110070 Solutions
New Discussion

copying the dot (.) files.

 
SOLVED
Go to solution
M Yasir Khan_1
Occasional Contributor

copying the dot (.) files.

Dear All,

when i try to copy whole directory structure using the command, from the source directory

# cd /source
# cp -p -R * /destination

this command doesn't copy the dot (.) files in the /source directory.

how can i accomplish this?

we are at hp-ux 10.20.

thanks and regards,

Yasir.
5 REPLIES 5
T G Manikandan
Honored Contributor
Solution

Re: copying the dot (.) files.

If u want to copy all the files
#cp -rp /source/*.* /destination

Now if you had already copied all the files except . files then
#cp -rp /source/.* /destination
Jan Zalman
Advisor

Re: copying the dot (.) files.

Also sometimes, a little trick is seen:

cd sourcedir ; tar cvf - . | ( cd destdir ; tar xvf - )

Regards
Jan
Time and loyalty cannot be bought.
Armin Kunaschik
Esteemed Contributor

Re: copying the dot (.) files.

Try

cp .??* _some_destination_

e.g. cp /etc/skel/.??* /home/wherever

This will copy only dot files with filenames
longer than 2 chars.

Armin
And now for something completely different...
Kevin Wright
Honored Contributor

Re: copying the dot (.) files.

don't use .* this won't give you expected results in all cases, IE chmod.

to match just the dot files use this
ls -la .[!.]*

and anything but a dot
ls -la [!.]

Bill Hassell
Honored Contributor

Re: copying the dot (.) files.

Yes, be very careful to NOT use .* as an expression. .* means: match . (the current working directory, which is OK) and also match .. (the parent directory which is BAD!). If you wanted to remove all the files in a particular directory, you might be tempted to use:

rm -rf * .*

which would match all files in the current directory and all the dotfiles (which is good) but also remove every file and directory above the current location. If this was /home/billh then the ENTIRE contents of /home will be removed (generally a bad thing). Always use the [!.] exclusion that eliminates . as the second character for a match.


Bill Hassell, sysadmin