Computing.Net > Forums > Unix > Simple script to copy files

Simple script to copy files

Reply to Message Icon

Original Message
Name: Morty
Date: January 22, 2003 at 06:39:35 Pacific
Subject: Simple script to copy files
OS: HPUX
CPU/Ram: P3
Comment:

I'm trying to automate a task I do to copy files. I have a reference file is always something like: 2110filenamehere.prn. I want to automate the cp command I use now. Only the 2110 part of the file name changes with each copy. The 2110 changes to: 2120, 2130, 2450, 2460 - the referencefile.prn is the constant. Can anyone help?
Thanks,
Mike


Report Offensive Message For Removal


Response Number 1
Name: Neel
Date: January 22, 2003 at 11:20:13 Pacific
Reply: (edit)

Have your tried with

cp 2???filenamehere.prn /

I think it will work.
njoy,

~ Neel !!


Report Offensive Follow Up For Removal

Response Number 2
Name: Morty
Date: January 23, 2003 at 05:41:49 Pacific
Reply: (edit)

Neel, thanks for responding however, I want to automate the copy function with a script. I know how to use cp and it is time consuming to retype the filenames.
I don't have enough knowledge to write a simple script to handle this in a batch.
Mike


Report Offensive Follow Up For Removal

Response Number 3
Name: Neel
Date: January 23, 2003 at 09:22:04 Pacific
Reply: (edit)

Well theres no need to retype the file names.. when you use the Wildcards as mentioned . It will copy all the files in the same format..
please let me know if am missing anythign ?


Report Offensive Follow Up For Removal

Response Number 4
Name: Heapster
Date: January 27, 2003 at 03:22:36 Pacific
Reply: (edit)

To automate this job create a file with your cp command in (using the wildcards shown above) and make that file executable.

Use the "crontab -e" command and create a line to run everyday to run the file you have created and hey presto, automation has occured!

If your are unsure about cron use the command "man crontab"


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Simple script to copy files

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge