[Ilugc] .a-tip-a-day. xargs command

  • From: kapil@xxxxxxxxxxx (Kapil Hari Paranjape)
  • Date: Mon Sep 21 16:40:05 2009

Hello,

On Mon, 21 Sep 2009, Roshan Mathews wrote:

On Mon, Sep 21, 2009 at 10:19 AM, Kapil Hari Paranjape
I got the same results which leads me to suspect that the original
tip is faulty.

The tip may not be faulty.

Perhaps you should try it and then make a pronouncement!

You could do this in a directory with a few files:
 $ mkdir /tmp/faultyfindq; cd /tmp/faultyfindq
 $ touch a{1..4}
 $ find . -type f | xargs nano

If you manage to do something sensible with the last command, then
please report it. (I have replaced vi with nano since Roshan seems to
dislike vi).

I suspect the problem is explained in this snippet from the man page
for xargs:

 --arg-file=file
 -a file
       Read items from file instead of standard input.  If you use
       this option, stdin remains unchanged when commands are run.
       Otherwise, stdin is redirected from /dev/null.

So the problem is that vi is run with stdin redirected from /dev/null
which will obviously not work.

Kapil.
--

Other related posts: