Kevin Vance - Thanks, GNU project. Thanks for this: xargs sh -c 'emacs "$@"…

Entries | Archive | Friends | Friends' Friends | User Info

03:08 am

Friday, September 3rd, 2010
Previous Entry Share Next Entry
Thanks, GNU project. Thanks for this:
xargs sh -c 'emacs "$@" < /dev/tty' emacs

Launches the minimum number of copies of Emacs needed, one after the other, to edit the files listed on xargs' standard input. This example achieves the same effect as BSD's -o option, but in a more flexible and portable way.
It is a great relief to know how flexible and portable GNU xargs is every time I have to look up that incantation in the man page. Taunting me with BSD xargs' -o option is an especially nice touch.

Current Mood elated
Current Music Mick Rippon - Existing
Link )Reply )

[User Picture]From: peadarog
2010-09-03 12:34 pm (UTC)
It's the favourite command of the data pirates: xarrrrrgs
(Reply) (Thread)
From: ext_239810
2010-09-05 11:46 pm (UTC)

More readable using GNU Parallel

If you have GNU Parallel installed you can do this to get all files in a single emacs:

cat filelist | parallel -Xj1 emacs

Do this to get them one at a time:

cat filelist | parallel -j1 emacs

It also deals nicely with filenames like:

12" records.txt

(Which your solution using xargs does not)

Watch the intro video for GNU Parallel to learn more:

(Reply) (Thread)
[User Picture]From: kvance
2010-09-06 01:28 am (UTC)

Re: More readable using GNU Parallel

That looks really, really useful. Thanks!
(Reply) (Parent) (Thread)
[User Picture]From: kartos
2010-09-08 04:55 am (UTC)
(Reply) (Thread)
[User Picture]From: kvance
2010-09-08 05:40 am (UTC)
Nope! Though I almost wish I had a few so I could run emacs on emacs.
(Reply) (Parent) (Thread)