>On Sunday 05 February 2006 20:00, Paul wrote:

>>          do device=`ls --full-time | grep $datum|awk '{print $9}'`
>
>Paul,
>I must be getting dense ....what's this line supposed to do?

$datum is filled with the date of today as yyyy-mm-dd.
Before the 'do device' is executed, a cd to /mnt is done.

The line in question determines the name of the usb-device that was
inserted 'today'. ls --full-time lists the contents of /mnt, pipes it
through grep which filters out the devices mounted today, and that
pushes the resulting ls-line through awk to get the name out of the line
(the ninth 'word').

It is stuck inside a 'do', because on my machine an inserted USBdevice
always takes a few seconds before it shows in the /mnt directory.

I use the --full-time with ls because a normal ls -l shows the date of
an entry as:

drwxr-xr-x   2 paul paul 4096 Jan 12 18:42 wavv/

where the --full-time one shows the same entry as:

drwxr-xr-x   2 paul paul 4096 2006-01-12 18:42:54.000000000 +0100 wav/

which is easier and safer to check with. Jan 12 can also be an entry
from 2005 or 2004. The resulting 2006-01-12 is matched to the generated
$datum variable in the grep. Would not match of course, as today is
2006-02-05, but then my wav directory is not a USB thing. *grin*


I admit that the script is not yet fool-proof, since I could stick 2
USBdevices in 2 ports on the same day. But I'll deal with that as time
progresses, it has not happened yet.


Perhaps this is a complicated way to do it, but it works for me.
As usual, with Linux, there is more than one way to do it. :-)

Paul

-- 
She got her looks from her father. He's a plastic surgeon.
- Groucho Marx

http://www.nlpagan.net/linux.php
Have you visited http://twiki.mdklinuxfaq.org yet?
____________________________________________________
Want to buy your Pack or Services from Mandriva? 
Go to http://store.mandriva.com
Join the Club : http://www.mandrivaclub.com
____________________________________________________

Reply via email to