- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- cp many files
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 08:12 AM
03-05-2003 08:12 AM
I have a directory that has about 83000 images in it and I want to break it up. The files are named LV100000, LV100001 etc.. How do I copy a range of files? i.e. LV100000-LV129000.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 08:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 08:54 AM
03-05-2003 08:54 AM
Re: cp many files
You could write a simple script.
--------------------------
# /usr/sbin/ksh
x=99
while [ $x != 129 ]
do
let x=x+1
cp LV$x000 /
done
---------------------------
where
Make the file Executable and run it. ./script
This is a very basic script and you can modify it to do many other tasks.
Have fun
And oh yea, as always say hi to Ken.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 09:01 AM
03-05-2003 09:01 AM
Re: cp many files
The easiest way would of course to split it in LV1*, LV2* and so on, but you may need to use finer regular expressions:
in a regular expression, [0-X] will contain all digits between 0 and X.
For instance, foo[0-3]bar will be true for foo0bar, foo1bar,foo2bar and foo3bar.
In the example that you gave, one command will not be enough:
cp LV1[0-2][0-8]* newdir will copy from LV100000 to LV128999.
cp LV129000 newdir will be mandatory to copy the last file...
if you have too many files, you may not be able to do it this way (too many arguments)...
Hope this helps,
FiX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 09:13 AM
03-05-2003 09:13 AM
Re: cp many files
You do have alot of files to copy. I think this is the script you want to use. I miss understood your file naming convention the first time around.
----------------------------
# /usr/sbin/ksh
x=99999
while [ $x != 129000 ]
do
let x=x+1
cp LV$x /
done
----------------------------
Don't forget to say hi to Ken
;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 09:16 AM
03-05-2003 09:16 AM
Re: cp many files
typeset -Z6 stopnum=1256
while [[ ${stopnum} -ge ${startnum} ]]
do
cp LV${startnum} /dest
(( startnum = ${startnum} + 1 ))
done
You just need to amend the values of startnum and stopnum.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 09:27 AM
03-05-2003 09:27 AM
Re: cp many files
Paul, Ken says email him. :)
Thanks for all these answers guys!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 09:28 AM
03-05-2003 09:28 AM
Re: cp many files
To avoid the "argument too long" error I'd be tempted to use the find command; though obviously running a large number of copies isn't great for performance!
Assuming you're in the dir with the image files:
find . -name 'LV1[0-2][0-9]000' -exec cp {} /dir_to_copy_to \;
should do the job.
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2003 12:04 AM
03-06-2003 12:04 AM
Re: cp many files
the typeset command is just going to pad the number with zeroes on the left hand side to make sure that the number is six digits.
To read about typeset do a "man ksh".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2003 09:34 AM
03-06-2003 09:34 AM
Re: cp many files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2003 09:35 AM
03-06-2003 09:35 AM
Re: cp many files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2003 02:05 PM
03-06-2003 02:05 PM
Re: cp many files
tar cvf - LV0000[0-9][0-9]|(cd DESTINATION;tar xvf -)
Copy 500 files: use LV000[0-4][0-9][0-9] for the first argument. Then to get the next 500, use LV000[5-9][0-9][0-9].
LV00[0-4][0-9][0-9][0-9] gets the first 5000 files.
And so on....
Try it: it goes a lot faster.
Chris