Bash or Perl example: copying data from a CD/DVD, to hard drive.
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Before you ask for examples maybe you'll formulate technical requirements ?
For example, who is "you" in <your initials> ? Current user ID ? User ID of the file owner on CD/DVD ?
What is <the date> ? I.e. file modification date on CD/DVD ? Current date ? Date entered on command line ?
What is <the directory name> ? I.e. what directory are you talking about ? Where should its name come from ?
Why are you asking about CD/DVD ? How data on mounted CD/DVD is different from any other data on disk (except for being read-only) ?
...
Have you read 'man cp' ? Do you know how 'cp -r ...' works ?
- The "me", is my current user ID: bluesword1969
- The "date" would be the current date.
- The directory name would be derived from the directory on the CD/DVD. So for instance:
US_EN_Speaker_data_vol1
This is a typical directory name that I find on a lot of the data CD's and DVD's that I encounter.
- It's not the mounting of the CD's and DVD's I'm really worried about. I'm using GNOME, so any disc that I pop in gets auto-mounted. I just want to open a shell, and fire up a script that copies the data right from the disc.
- The "me", is my current user ID: bluesword1969
- The "date" would be the current date.
- The directory name would be derived from the directory on the CD/DVD. So for instance:
US_EN_Speaker_data_vol1
This is a typical directory name that I find on a lot of the data CD's and DVD's that I encounter.
- It's not the mounting of the CD's and DVD's I'm really worried about. I'm using GNOME, so any disc that I pop in gets auto-mounted. I just want to open a shell, and fire up a script that copies the data right from the disc.
- Yes, I know what cp (-r) does. :-)
Thanks!
Then in Perl there is getpw* functions (see 'perldoc perlfunc' for them) to get user ID. You might end up with
Code:
chomp(my $user = `whoami`);
though.
Read about 'File::Spec', 'File::Basename', 'File::Path', 'Cwd' Perl modules for efficient dealing with paths.
Regarding date - look for "Perl date time modules".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.