Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CP

Posted on 2012-03-11
6
Medium Priority
?
326 Views
Last Modified: 2012-03-27
Good evening,
Im a newbie with linux, and Ive figured out I can do "CP -R" to copy all files and directories, which works great, but if Im doing several Gb, I have no idea how far its got, or if its failed.

Is it possible to add a parameter in to show me which files its copying/copied, and maybe the progress of the current file?

On another question, is it possible to tell it to skip files if they exist already, or overwire if it does exist.

Thank you
0
Comment
Question by:tonelm54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 37707673
I don't know any way cp will show progress.  You might want to look at the -a option.

To not overwrite exisitng files, use -n.  You might also want to look at -u.

See http://linux.die.net/man/1/cp
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 37707675
I'm not sure what you want with overwrite if they exist.  I think you want -f.  Again, see the man page at http://linux.die.net/man/1/cp
0
 
LVL 48

Expert Comment

by:Tintin
ID: 37708079
What you want to use is rsync, eg:

rsync -av --stats --progress /source/dir /dest/dir
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 44

Accepted Solution

by:
Darr247 earned 2000 total points
ID: 37708553
Look at these switches/parameters and see which of them you want to use...

# \cp -cfpv

the # means you're at root-level access (user-level access has $ prompt)
the \ makes it ignore parameters that have been stored as defaults and use only the parameters specified
the c makes it preserve the 'context' so SELinux shouldn't complain about wrong context
the f makes it 'force'  an overwrite
the p makes it preserve the date/time stamp, otherwise they're set to the moment copied
the v makes it verbose

other switches you might find useful immediately
the r makes it recursive
the n makes it NOT overwrite (aka "no-clobber")
the u makes it overwrite only if the file being copied is newer (another reason to use -p)

Without using \ you probably won't be able to use -f or -u, because I think most distros store -n (no-clobber) as a default, so cp ignores the overwrite and update switches.

In my opinion, the most important thing to know about linux commands is 'man' e.g.
$ man cp
and use PgDn/PgUp to scroll down/up through the help file. Press 'q' to quit man pages.
Any [command] you're not sure how to use, and what parameters it has, just run
$ man [command]
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 37709318
I'd like to note that running at the #, especially for commands you don't understand, is a bad idea, especially for a newbie unless it's a "sandbox" system that you are willing to reload (as people did a lot in the old days of Linux).
0
 
LVL 48

Expert Comment

by:Tintin
ID: 37774093
You are still much better off to use rsync.   For your purposes it will be way quicker and use much fewer resources.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question