C-shell fails to execute commands with arguments using wildcard characters.
eg.,
% \rm -rf *
Arguments too long
% ls -l | wc
8462 76151 550202
The reason for this failure is that the wildcard has exceeded C-shell limitation(s). The command in this example is evaluating to a very long string. It overwhelmed the
csh limit of 1706, for the maximum number of arguments to a command for which filename expansion applies.Workarounds:
- Use multiple commands Or
- Use xargsutility% \rm -rf * Or
 Arguments too long
 % ls | xargs rm -rf
 % ls
 %% \rm -rf * 
 Arguments too long
 % find . -name "*" | xargs rm -rf
 % ls
 %
From Jerry Peek's Handle Too-Long Command Lines with xargs:
- xargsreads a group of arguments from its standard input, then runs a UNIX command with that group of arguments. It keeps reading arguments and running the command until it runs out of arguments.
- The shell's backquotes do the same kind of thing, but they give all the arguments to the command at once. That's the main reason for the Arguments too longerror, when the shell reaches its limitations
Reference:
Man page of
cshThanks to Chris Quenelle for suggesting the
xargs workaround
 
 
 
 
 
 
0 comments:
Post a Comment