zamykani souboru v shellu

Jan Kasprzak kas na informatics.muni.cz
Středa Říjen 29 14:52:24 CET 2003


Petr Stehlik wrote:
: if [ -f $LOCKFILE ]
: then
: 	MYLOCK=0
: else
: 	touch $LOCKFILE
: 	MYLOCK=1
: fi

	Pokud nejste na NFS, tak by melo stacit

set -o noclobber
if ( : > $LOCKFILE ) 2>|/dev/null
then MYLOCK=1
else MYLOCK=0
fi
set -o clobber

Mozna je i elegantnejsi zpusob, jak zahodit ten stderr.

-Y.

-- 
| Jan "Yenya" Kasprzak  <kas at {fi.muni.cz - work | yenya.net - private}> |
| GPG: ID 1024/D3498839      Fingerprint 0D99A7FB206605D7 8B35FCDE05B18A5E |
| http://www.fi.muni.cz/~kas/   Czech Linux Homepage: http://www.linux.cz/ |
|  I actually have a lot of admiration and respect for the PATA knowledge  |
| embedded in drivers/ide. But I would never call it pretty:) -Jeff Garzik |


Další informace o konferenci Linux