[TriLUG] Scripting & C++ question

Ed Hill ed at eh3.com
Fri Nov 11 17:31:31 EST 2005


On Fri, 2005-11-11 at 17:08 -0500, Kevin Otte wrote:
> On Fri, Nov 11, 2005 at 04:51:31PM -0500, Mark Freeze wrote:
> > On 11/11/05, Ed Hill <ed at eh3.com> wrote:
> > > Try:  "ls /home/mark/programs/cpp | xargs ./arg_test"
> 
> Please bear in mind that there is an upper limit to the number of command
> line parameters.  This is mitigated by xargs, but doing something like:
> 
> ls *
> 
> will cause the * to be expanded by the shell and hit this limit.
> 
> For the full gory details see the relevant TriLUG discussion at:
> http://www.trilug.org/pipermail/trilug/Week-of-Mon-20051017/038048.html


Yes.  And there are a few different ways around the command line length
issue including both xargs and the bash read syntax:

  i=0
  while test ! $i = 10000 ; do
      touch 'file_'`printf %010d $i`
  done
  find . -name file_\* | while read line ; do
      mv $line ../some/other/dir/
  done

so happy scripting!

Ed

-- 
Edward H. Hill III, PhD
office:  MIT Dept. of EAPS;  Rm 54-1424;  77 Massachusetts Ave.
             Cambridge, MA 02139-4307
emails:  eh3 at mit.edu                ed at eh3.com
URLs:    http://web.mit.edu/eh3/    http://eh3.com/
phone:   617-253-0098
fax:     617-253-4464




More information about the TriLUG mailing list