command line question

der.hans PLUGd at LuftHans.com
Tue Jan 29 16:18:49 MST 2013


Am 29. Jan, 2013 schwätzte Kevin Fries so:

moin moin Kevin,

> I am surprised nobody gave this answer, at least as far as I saw:
>
>   $ /path/to/command &> /dev/null

A couple of us did, except we spelled it correctly :)

'&>/dev/null' is a bashism for '>/dev/null 2>&1'. There's nothing wrong
with it for bash scripting, but I find the latter to be easier to read,
far more common and more portable, so that's what I use for teaching and
giving answers on mailing lists.

In a bash only environment, either is fine, but when working with other
Bourne shell derivatives your syntax might not work. It might work in
zsh, but I'm pretty certain it isn't allowed in POSIX shell or ksh and it
definitely isn't in the original Bourne shell.

A really cool feature of a good toolset is there is more than one way to
do it :).

ciao,

der.hans

> Kevin
> On Jan 29, 2013 3:27 PM, "Matt Graham" <danceswithcrows at usa.net> wrote:
>
>> From: joe at actionline.com
>>> I still can't get either to work.
>>> James: gwenview filename.jpg > /dev/null 2>&1 &
>>> Hans:  gwenview filename.jpg 2>/dev/null &
>>>
>>> Both examples work to cause gwenview to open filename.jpg without
>>> any error messages. However, when I close the terminal window,
>>> gwenview also closes.  What am I doing wrong?
>>
>> To stop a process from dying when its parent tty dies, you probably want
>> nohup.  "nohup gwenview filename.jpg > /dev/null 2>&1 &" .  The
>> xterm/konsole
>> will still be there, though you can then manually close it.
>>
>> If this approach *did* automagically close the xterm, it'd be functionally
>> equivalent to just starting gwenview from the mini-commandline....
>>
>> --
>> Matt G / Dances With Crows
>> The Crow202 Blog:  http://crow202.org/wordpress/
>> There is no Darkness in Eternity/But only Light too dim for us to see
>>
>> ---------------------------------------------------
>> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>
>

-- 
#  http://www.LuftHans.com/        http://www.LuftHans.com/Classes/
#  When I work, I work hard. When I play, I play hard.
#  When I sit, I sleep. - Embe Kugler


More information about the PLUG-discuss mailing list