Operating System - HP-UX
1833640 Members
3622 Online
110062 Solutions
New Discussion

rcp missing hidden files.

 
Russ Hancock_1
Frequent Advisor

rcp missing hidden files.

I'm issuing a rcp command to copy files/directories between machines. The problem is the resulting directory is missing any hidden files/directories.

Is there a flag I can set to make sure the hidden files go across.

I'm using rcp -rp hosts:/file /file2
Russ
6 REPLIES 6
Armin Feller
Honored Contributor

Re: rcp missing hidden files.

Hi,

I'd never heared about such a problem. Please check with 'ncheck' if there are realy hidden files.

Regards ...
Armin
Robert-Jan Goossens
Honored Contributor

Re: rcp missing hidden files.

Hello Russ,

Can't find an option for rcp to include hidden file, but you can use find in combination with cpio.

# cd /home/user
# find . | cpio -ov | remsh server " cd /home/user ; cpio -idvum "

Robert-Jan.
BFA6
Respected Contributor

Re: rcp missing hidden files.

Hi,

I'm not aware of any flags fro rcp for hidden files. I've just used rcp to copy a users home directory & all of the hidden files have come across OK.

Regards,

Hilary
Scott Corzine
Advisor

Re: rcp missing hidden files.

Hi-

When rcp -r is copying a directory (rcp -rp host:/remotedir /localdir), it should always include all files it can read, hidden or otherwise. If it doesn't then it's broken.

When you use "rcp -rp hosts:/file /file2" (explicitly naming the files), rcp will copy those filenames it is given by the shell (after wildcard expansion). If that includes hidden files, they should be copied.

Is there a chance you're doing something like "rcp -rp hosts:/* /localdir"? That would ignore hidden files because the * wildcard won't match them.

-Scott-

Bill Hassell
Honored Contributor

Re: rcp missing hidden files.

rcp handles hidden files just fine. The problem is that you are not specifying them in the command line. A hidden file (files that start with .) are 'hidden' from standard filename generation by the shell. If you type echo *, you won't see any . files, so rcp * produces the same result. Like ls, rcp and echo don't know anything about filename expansion--the * is just a character. Turn off the shell's special handling with the \ character and type the echo command as in: echo \* and you'll see just * not filenames.

So to get hidden files, DO NOT TYPE rcp .*!!!!! To see what you will get, always use echo first as in echo .* ...if you are in a subdirectory, you will be very surprised to see directories and files one level up in the listing! That's because .* matches the hidden directory called: .. which is a real directory, and not what you want.

The easiest solution is to use rcp's ability to copy an entire directory with -r as in:

rcp -r /some_directory_path ...

or if you need just the files in a specific directory, use a regular expression that finds the hidden files but not the .. directory as in:

echo * .[!.]*

and

rcp * .[!.]*

The regular expression .[!']* says: match all normal files and directories (*) and then match all files that start with . but not files that have a . in the second character. This will miss files that start with .. but they can be handled with .??* which matches all files starting with . followed by any 2 characters or more.


Bill Hassell, sysadmin
Steve Labar
Valued Contributor

Re: rcp missing hidden files.

If you are copying an entire directory rcp -r should work. As Bill pointed out, if you are copying files instead of directories, rcp * will not pick up dot files. I use .??* whenever I want to include dot files. This will include any dot file that is 3 characters or more (not . or ..). Be careful there can also be dot directories which could choke if you are not using the -r option.

Good Luck.

Steve