DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 23rd March 2016
jjstorm jjstorm is offline
Package Pilot
 
Join Date: Nov 2014
Location: Buenos Aires, AR
Posts: 144
Default cp, mv, and chown command options

I want to know, if it is possible to copy all files within one directory to another directory without copying the directory itself, and at the same time, change ownership of those files at their destination, all in one command?

For example:

Lets say I want to copy all files within the /mnt/Documents directory to /home/user/Documents. When the files arrive at their destination, I want all of the permissions to have changed to the user and group I designate, but remain the same at their original location.

I checked the man pages for cp and mv, but I did not see a way to accomplish the first part, that is, to copy all files within the directory without copying the directory itself. I think if this part can be accomplished, then the permissions can probably be changed as each file arrives at its destination.
Reply With Quote
  #2   (View Single Post)  
Old 23rd March 2016
e1-531g e1-531g is offline
ISO Quartermaster
 
Join Date: Mar 2014
Posts: 628
Default

Maybe instead of:
Code:
cp -R /mnt/Documents /home/user/Documents/
just:
Code:
cp -R /mnt/Documents/* /home/user/Documents/
or
Code:
for VAR_ONE in `ls -1 /mnt/Documents/` ; do cp -R /mnt/Documents/${VAR_ONE} /home/user/Documents/ ; done ;
I would test this to see if hidden files/directories are copied. Now I use Windows so I can't at the moment.

Last edited by e1-531g; 23rd March 2016 at 09:16 PM. Reason: added third command with for loop
Reply With Quote
  #3   (View Single Post)  
Old 23rd March 2016
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,983
Default

See install(1). You can copy files and set owner and filemodes in one utility.
Reply With Quote
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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PF and Stateful Tracking Options mfaridi OpenBSD Security 9 15th April 2010 09:05 AM
resetting make options? carpman FreeBSD Ports and Packages 1 27th March 2010 12:54 PM
Find command (Linux options?) deadeyes FreeBSD General 11 23rd August 2009 06:07 PM
How to get port's building options? Sunsawe FreeBSD Ports and Packages 14 9th May 2009 06:35 PM


All times are GMT. The time now is 06:15 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick