- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Arguments too long
Operating System - HP-UX
1820636
Members
1852
Online
109626
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО04-01-2010 08:10 PM
тАО04-01-2010 08:10 PM
Arguments too long
Hi there,
Apparently I keep recieve an error message when I try to copy some files to other directory.
/% cp /export1/uw/ECM/images/BGIR2093*.txt /export1/uw/ECM/backup/images
Arguments too long.
Please assist.
Apparently I keep recieve an error message when I try to copy some files to other directory.
/% cp /export1/uw/ECM/images/BGIR2093*.txt /export1/uw/ECM/backup/images
Arguments too long.
Please assist.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2010 12:26 AM
тАО04-02-2010 12:26 AM
Re: Arguments too long
for i in /export1/uw/ECM/images/BGIR2093*.txt
do
cp $i /export1/uw/ECM/backup/images
done
Or
ls /export1/uw/ECM/images/BGIR2093*.txt | xargs -i -t cp {} /export1/uw/ECM/backup/images
do
cp $i /export1/uw/ECM/backup/images
done
Or
ls /export1/uw/ECM/images/BGIR2093*.txt | xargs -i -t cp {} /export1/uw/ECM/backup/images
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2010 01:15 AM
тАО04-02-2010 01:15 AM
Re: Arguments too long
> for i in /export1/uw/ECM/images/BGIR2093*.txt
This "for" command line has the same risk of being too long after wildcard expansion as the original cp command.
The trick is to use "find" and pass any necessary wildcards to it in quotes, so they won't be expanded by the shell.
But the "find" command looks into sub-directories too, so you should verify it does what you want before actually making it do anything that's difficult to undo:
find /export1/uw/ECM/images -name 'BGIR2093*.txt' -exec echo cp {} /export1/uw/ECM/backup/images/ \+
This should display a list of (probably very long) "cp" commands. If the commands look OK, just remove the "echo" in the middle and the cp commands will be actually executed, instead of displayed.
Limiting "find" to a single directory in a portable way may be tricky:
http://www.in-ulm.de/~mascheck/various/find/
MK
This "for" command line has the same risk of being too long after wildcard expansion as the original cp command.
The trick is to use "find" and pass any necessary wildcards to it in quotes, so they won't be expanded by the shell.
But the "find" command looks into sub-directories too, so you should verify it does what you want before actually making it do anything that's difficult to undo:
find /export1/uw/ECM/images -name 'BGIR2093*.txt' -exec echo cp {} /export1/uw/ECM/backup/images/ \+
This should display a list of (probably very long) "cp" commands. If the commands look OK, just remove the "echo" in the middle and the cp commands will be actually executed, instead of displayed.
Limiting "find" to a single directory in a portable way may be tricky:
http://www.in-ulm.de/~mascheck/various/find/
MK
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2010 02:18 AM
тАО04-02-2010 02:18 AM
Re: Arguments too long
>Matti: -exec echo cp {} /export1/uw/ECM/backup/images/ \+
Unfortunately you can't use {} with + except last. You'll need to create a script that reverses the first parm with the last:
find ... -exec cp_reverse /export1/uw/ECM/backup/images/ {} +
#!/usr/bin/sh
target=$1
shift
cp "$@" "$target"
>Laurent: ls /export1/uw/ECM/images/BGIR2093*.txt | xargs
This will also fail. You need to add add grep to the pipeline and you would have to cd to that directory:
cd /export1/uw/ECM/images
ls | grep "\.txt$" | xargs ...
Also if you cd to the directory, you may be able to use:
cp BGIR2093*.txt /export1/uw/ECM/backup/images
Unfortunately you can't use {} with + except last. You'll need to create a script that reverses the first parm with the last:
find ... -exec cp_reverse /export1/uw/ECM/backup/images/ {} +
#!/usr/bin/sh
target=$1
shift
cp "$@" "$target"
>Laurent: ls /export1/uw/ECM/images/BGIR2093*.txt | xargs
This will also fail. You need to add add grep to the pipeline and you would have to cd to that directory:
cd /export1/uw/ECM/images
ls | grep "\.txt$" | xargs ...
Also if you cd to the directory, you may be able to use:
cp BGIR2093*.txt /export1/uw/ECM/backup/images
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP