Haifux: Quick and Dirty Bash strikes again!

2014-01-01 Thread Eli Billauer




Hello all,
On Monday (January 6th), Haifux will re-run its good old Schlager "Quick
and Dirty Bash". Anyone who wants to get a better grip on one-liners in
bash and some basic scripting, this is the place and time.
The slides are available at
http://www.haifux.org/lectures/100-sil
This is an extra announcement, as the lecture was added at short
notice.
See you,
   Eli

-- 
Web: http://www.billauer.co.il




___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il


Re: Haifux: Quick and Dirty Bash strikes again!

2014-01-01 Thread Amos Shapira
A new trick I learned since the previous round (as far as I remember):

jobs -x command which takes pid % will pass the job's pid to the command,
e.g.

$ long running command 
[1] 52282
$ jobs -x watch pstree -pall %

Will pass 52282 to pstree.

You can stick any background job reference instead of just plain % (which
refers to the current default background job), and of course you can
stick multiple job references anywhere on the command line.

You can use the jobs on the same command line as the one when the
background job is started:

$ find /  /dev/null 21  jobs -x watch pstree -pall %

This would give the same result as $! but more flexible about which
background job is used, e.g. I commonly do:

$ command  /tmp/file 21  tail --pid $! -F /tmp/file

to watch a long running background process' output and keep its log output
in a file. tail's --pid means that it'll exit when that pid terminates
and Bash replaces the $! by the pid of the last started background job.

It's probably useful for bash functions/aliases (e.g. I'd like to alias the
tail command above so I don't have to repeat the output file name in both
the watched command and the tail), though I haven't got around to construct
such an alias yet (submissions would be gladly accepted :) ).

--Amos



On 2 January 2014 07:19, Eli Billauer e...@billauer.co.il wrote:

  Hello all,

 On Monday (January 6th), Haifux will re-run its good old Schlager Quick
 and Dirty Bash. Anyone who wants to get a better grip on one-liners in
 bash and some basic scripting, this is the place and time.

 The slides are available at

 http://www.haifux.org/lectures/100-sil

 This is an extra announcement, as the lecture was added at short notice.

 See you,

Eli

 --
 Web: http://www.billauer.co.il


 ___
 Linux-il mailing list
 Linux-il@cs.huji.ac.il
 http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il




-- 
 [image: View my profile on LinkedIn]
http://www.linkedin.com/in/gliderflyer
___
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il