cp command not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cp command not working
# 8  
Old 02-21-2010
Quote:
Originally Posted by Geekasaurus
The cp command does not work for directories with large number of files in them. I don't know what the upper limit is; I could probably find out with a lot of research. Also, the mv and rm commands do not work either under the same circumstance.

...snip...

The shell being used does not matter. Neither does the OS (particularly). It is the same cp command (or rm, or mv) regardless of the shell.
Actually, the operating system definitely matters. A command line length limit has nothing to do with the executables (rm, mv, cp, tar, etc...); it is a byproduct of limits imposed on the system call which creates the process. In situations like these, find and/or xargs are our friends.

This may be of interest to some:
ARG_MAX, maximum length of arguments for a new process

Take care,
Alister
# 9  
Old 02-21-2010
The Find Command

This event was in 2002, and so I have forgotten many of the details. I think the find command also barfed. But it was 3AM, of course, and I must've tried a lot of things before settling on the 'for' script.

Hpux 11.0 was a 32bit OS. And it was on a HP V-class machine which had some very Byzantine I/O constraints. Nevertheless I have almost always had success with the tar command but have had my share of troubles with the others.

And note that I qualified my statement with the word "particularly". We had some Tru64 systems which had absolutely no trouble with this sort of problem. I suspect that most/all 64bit OS's will not demonstrate this kind of problem.

It was not a technical reason that I chose to remove one file at a time. The system in question processed several billion dollars in transaction volume with every batch run. I was expected to 'do something' about the problem rather than actually fix it. You know that it will be a bad day at the office when the Public Affairs Officer shows up in the Data Center at 4AM in her pajamas. At least with all those filenames scrolling up across the screen, I could say that something was being done, even if it was not particularly elegant or technically desirable.
# 10  
Old 02-22-2010
running ./configure on a 64-bit linux system:

Code:
...
checking the maximum length of command line arguments... 1572864
...

So, 1.5 million instead of 64 thousand. Which is a lot, but only 24 times larger, and still not big enough for your absolute worst-case scenario there. The rule of thumb is, if you're using enough arguments enough to even ask "does my OS support it" the only truly safe answer is "no" -- even if it works now it won't scale, and won't be portable. If you have that many already you could always have more, you'll find out your OS' limit in an inconvenient way sooner or later.

I can certainly appreciate needing to make an emergency solution. Four million files!! Smilie

Last edited by Corona688; 02-22-2010 at 02:33 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

2. UNIX for Dummies Questions & Answers

Shell script not working but command works in command prompt

Hi everyone I have a problem with my script If I try directly this command /usr/bin/nice -n 19 mysqldump -u root --password="******" wiki_schneider -c | nice -n 19 gzip -9 > /point_de_montage/$(date '+%Y%m%d')-wiki-db.sql.gz It works But if I simply add this command in a script and... (8 Replies)
Discussion started by: picemma
8 Replies

3. Shell Programming and Scripting

Maxdepth command not working in AIX.Need alternative solution for this command

Hi All, I am trying to select 30 days older files under current directory ,but not from subdirectory using below command. find <Dir> -type f -mtime + 30 This command selecting all the files from current directory and also from sub directory . I read some documention through internet ,... (1 Reply)
Discussion started by: kommineni
1 Replies

4. Shell Programming and Scripting

Working of command

What does the command do lpr -Pqpr *.jpg do ? (1 Reply)
Discussion started by: Nabeel Nazir
1 Replies

5. Shell Programming and Scripting

help with shell script: cp command not working, but mv command works...

Hello. I would like to ask your help regarding the cp command. We are using a cp command to create a back-up copy of our file but to no avail. It's just not working. We already checked the file and directory permissions and all seems correct. We have a script (ftp.script) which calls on... (1 Reply)
Discussion started by: udelalv
1 Replies

6. Shell Programming and Scripting

Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone, when executing this command in unix: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csvIt works fine, but running this command in a shell script gives an error saying that there's a syntax error. here is content of my script: tdbsrvr$ vi hc.sh "hc.sh" 22 lines, 509... (4 Replies)
Discussion started by: 4dirk1
4 Replies

7. UNIX for Advanced & Expert Users

command for recently modified files - "find" command not working

I have three files a.txt , b.txt , c.txt in a directory called my_dir1 .These files were created before two or three months . I have a tar file called my_tar1.tar which contains three files a.txt , b.txt , d.txt . Somebody untarred the my_tar1.tar into my_dir1 directory. So existing two files were... (1 Reply)
Discussion started by: joe.mani
1 Replies

8. Shell Programming and Scripting

Here command not working

The below is a simple script, but doesnt work. #!/bin/ksh cat <<XYZ -h help -T Test (required) -D Develop (required) XYZ Help is appreciated (5 Replies)
Discussion started by: pinnacle
5 Replies

9. Solaris

ls command not working

Hi, I have installed opensolaris 10 in VMware. Everything is fine except ls command is not working. It is not displaying any files and directories. Sorry if the question is soo trivial. (8 Replies)
Discussion started by: mayahari
8 Replies

10. Solaris

last command not working

I have a Solaris 8 Ultra 1 on my network that we use as a utility server. The last command, which looks in the /var/adm/wtmpx file, is not working. When I do a last, the latest entry is dated June 3, but the /var/adm/wtmpx file is dated whenever a login is successful (verified by typing a... (3 Replies)
Discussion started by: antalexi
3 Replies
Login or Register to Ask a Question