Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
If I have 2 folders/directories namely folder-A/directory-A and folder-B/directory-B
What will be the most convenient command (plus correct syntax) shall I use;
1) to copy all sub-folders/sub-directories including all files inside from folder-A/directory-A to folder-B/directory-B.
2) to copy all sub-folders/sub-directories only EXCLUDING all files inside from folder-A/directory-A to folder-B/directory-B
3) only to copy the FIRST and SECOND levels of the sub-folders/sub-directories, i.e. the sub-folders/sub-directory immediate under folder-A/directory-A and their immediate sub-folders/sub-directories, EXCLUDING all files inside.
What I am trying to find is a combination of commands to do the jobs.
(Remark:
Previously I meant Folder-A=User-A and Folder-B=User-B
Acturally I need to create the exact set of folders and sub-folders to User-B, User-C, etc. same as User-A)
Currently I apply 'cp' and 'mc' to do the jobs as listed in my first posting as follows;
Using 'mc' to copy all folders, sub-folders and files from User-A to User-B, then removing all files. Afterwards using 'mc' again to copy all folders and sub-folders from User-B to User-C, User-D etc.
I have been searching on Internet with google but up to now still I have not found a solution.
Lot of thanks for your advice which is very interesting to me.
I thnk I should spare some time learning C++ and Bash/Shell script languages
If I save
Code:
cd /home/user1
find . -type d -name '*' \
-exec mkdir -p /home/user2/{} \;
to a file namely "cpdir" and want to make it executable
1) what will be the file extention '.sh' or '.exe'
2) where shall I save it? '/bin/'?
3) how to activate it so that it can be executed by typing "cpdir + ENTER" on Konsole window? With 'chown'?
4) how to make 'user2' variable for 'user2','user3', 'user4', 'userX', etc. so that I am allowed to copy the directory structure to either 'user2', 'user3' or 'user4' individually. Similarly I am also allowed to copy the directory structure to 'user2', 'user3', 'user4', etc.collectively.
There is a niffty tool called dialog but I haven't actually created any scripts using this.
You may have better luck with good advice down at the program section.
Originally posted by homey There is a niffty tool called dialog but I haven't actually created any scripts using this.
You may have better luck with good advice down at the program section.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.