1752577 Members
4987 Online
108788 Solutions
New Discussion юеВ

Re: rcp hidden files

 
SOLVED
Go to solution
juno2
Super Advisor

rcp hidden files

I want to coyp all file from one host to another host , but some of source files are hidden and start with a "." sign like .profle , does the command rcp support these type of files ? thx.
6 REPLIES 6
Darren Prior
Honored Contributor
Solution

Re: rcp hidden files

Yes. As with any "." files, you'll need to use the wildcard .* (DOT STAR)

regards,

Darren.
Calm down. It's only ones and zeros...
Stefan Farrelly
Honored Contributor

Re: rcp hidden files

rcp does indeed support copy files starting with a .

If you rcp -r a directory which contains . files then all copy across. If you copy the files in the current dir of which some start with a . then it wont copy them, you will need 2 rcp commands; rcp * then rcp ./.*, or copy the parent directory instead, then it will include the . files.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Simone Benzi_1
Frequent Advisor

Re: rcp hidden files

Ciao,

rcp follows same rules than cp, in order to copy hidden files you have to run something like:

rcp -p .[psXc]* remotehost:/path

where p, s, X and c are the first letter of your hidden files.

Regards,

Simone
Robert-Jan Goossens
Honored Contributor

Re: rcp hidden files

Hi,

Or you can use find in cobination with cpio

# cd /dir
# find . | cpio -ov | remsh host "cd /dir ; cpio -idvum"

Hope it helps,

Robert-Jan.
Bill Hassell
Honored Contributor

Re: rcp hidden files

rcp knows nothing about wildcard characters, just as echo or cat or cp know nothing about * or ? characters. These wildcards are processed by the shell long before rcp sees the command line. To prove this, use the two commands:

echo .*

echo .\*

The \ character removes the 'special' meaning of * and echo simply reports what the shell has done to the command line. So remember that ? and * (and []{}, etc) are processed by the shell, not the command itself.

Also, .* is a very commonly misused. .* means: return any filename with . as the first character followed by zero or more characters. What is often unexpected is that .* will return .. which is the parent directory. So using the rm -r .* command in a user's directory could destroy the entire /home directory structure! Always 'test' the rm -r command with either the -i option (asks for confirmation on every file deletion) or add the word echo in front of rm -r to see what the shell will do:

echo rm -i .*


Bill Hassell, sysadmin
Steven E. Protter
Exalted Contributor

Re: rcp hidden files

Warning: I've seen some unusual behavior on 11.00 with rcp recursive commands.

Say copy the /oracle filesystem from system to system.

rcp -p -r /oracle/*.* hostname:/oracle

Different number of bytes at the back end.

scp -p -r has not led to the same problem.
Gott love Secure Shell.
http://www.software.hp.com/cgi-bin/swdepot_parser.cgi/cgi/displayProductInfo.pl?productNumber=T1471AA

You are better off using cpio or tar. If you are replicating a whole system, consider Ignite Golden Images.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com