LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-06-2015, 09:47 AM   #1
rockstar05
Member
 
Registered: Dec 2011
Posts: 83

Rep: Reputation: Disabled
Unhappy Copy command difficulties.


Hi All,

I'm coping some files from my home directory to some other location, but it won't copy hidden files.

I used following command to copy,
Quote:
cp *.* pvt/
can anyone tell me why its not coping hidden files ?

Thanks for your help,

Regards,
 
Old 04-06-2015, 09:55 AM   #2
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
I'll admit I find the copying of hidden files in bulk a little confusing myself so I'll post a link:
https://www.linuxquestions.org/quest...nother-387107/
Because what I wanted to post is that "*.*" is a DOS thing and unless that's exactly what you want to do -- copying all files which have some characters, then a dot, then some characters, you shouldn't use it under Linux. With Linux there are often no "file extensions" so when wanting to copy everything it's simply:
Code:
cp * /the/destination/
Though, as discussed in the thread I linked to, that doesn't copy files beginning with a dot either.
 
Old 04-06-2015, 10:28 AM   #3
rockstar05
Member
 
Registered: Dec 2011
Posts: 83

Original Poster
Rep: Reputation: Disabled
Still have some problem to copy my .bash_history, .bashrc,.bashrc.bak,.lesshst,.profile,.profile.belvedere,.ssh files to new directory.
 
Old 04-06-2015, 10:35 AM   #4
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Check the link I posted to an earlier question. There are a few solutions given. I'd probably go with the simple approach given in post #11.
 
Old 04-06-2015, 11:11 AM   #5
rockstar05
Member
 
Registered: Dec 2011
Posts: 83

Original Poster
Rep: Reputation: Disabled
Here, does * means all files in a directy including hidden files ??

but they can not take all files, why ??
does I need to use another command instead of cp.
 
Old 04-06-2015, 11:13 AM   #6
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
No, just using * won't copy hidden files, just how it's designed I suppose.
What exactly are you trying to do though? A graphical file manager would allow you to copy anything you want, for example. Or something like rsync can be used to synchronise files. Or, you could just copy your full home directory to somewhere else if that's all you want to de.
As I mentioned check out the thread I linked to for other ideas.
 
Old 04-06-2015, 11:46 AM   #7
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
For copying all files from your home directory to another location you can use:

Code:
cp -arv /home/your_home_directory/. /destination
You can try using -arv with * not sure whether it will result in what you are looking for.
 
Old 04-06-2015, 12:43 PM   #8
rockstar05
Member
 
Registered: Dec 2011
Posts: 83

Original Poster
Rep: Reputation: Disabled
stil not what I'm looking for ... :-(
 
Old 04-06-2015, 12:45 PM   #9
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Give us an example of what exactly you are trying to do, let me see if I can replicate that and give it a try.
 
Old 04-06-2015, 12:57 PM   #10
rockstar05
Member
 
Registered: Dec 2011
Posts: 83

Original Poster
Rep: Reputation: Disabled
I have my profile with lot of hidden files such as .bash_history, .bashrc,.bashrc.bak,.lesshst,.profile,.profile.belvedere,.ssh, and I want to copy all files from my profile(including hidden) to directory like /pvt.

should i go with rsync or cp will do this ?
 
Old 04-06-2015, 01:03 PM   #11
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
If that is the case then cp should work. I have got many hidden files in my profile as well and I have copied my entire home directory to /tmp and it copied hidden files as well. I used the same command as I mentioned in my previous post:

Code:
cp -arv /home/your_home_directory/. /destination
Make sure you are putting a dot (.) as I mentioned in the source. If it does not work then you have to explain the requirement in more detail because on the basis of what you said it works perfectly fine for me.

You can use rsync but I don't see anything wrong with cp.
 
Old 04-06-2015, 01:07 PM   #12
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
By the way, I made mention of rsync because I have no idea what the full requirement here is. rsync works well for keeping things synchronised, the clue in the name, but for a one off copy I'd probably not use it.
 
Old 04-06-2015, 01:16 PM   #13
rockstar05
Member
 
Registered: Dec 2011
Posts: 83

Original Poster
Rep: Reputation: Disabled
Quote:
cp -arv /home/your_home_directory/. /destination
it works with absolute path.

I tried without absolute path, so it does not copy hidden files.

It works

Thanks :-)
 
Old 04-06-2015, 01:20 PM   #14
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
You're welcome.

Please mark the thread as solved!

Enjoy Linux!!!
 
Old 04-06-2015, 01:22 PM   #15
rockstar05
Member
 
Registered: Dec 2011
Posts: 83

Original Poster
Rep: Reputation: Disabled
Done Thanks .. ..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
in sed command , I have difficulties to understand /1/2 seanrobi Programming 9 08-08-2010 12:09 PM
how to copy drive using dd and tee command parallely? source code of dd command mdfakkeer Linux - Software 1 02-10-2010 01:31 PM
Command for copy juber Linux - Newbie 4 08-23-2008 07:54 AM
copy command jkeertir Linux - Newbie 3 05-29-2008 11:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration