[ale] BASH question

JD jdp at algoloma.com
Sun Jun 26 16:46:02 EDT 2011


On 06/26/2011 03:58 PM, John Pilman wrote:
> I want to write a shell script or alias to allow me to cd to a
> particular directory more easily.
> 
> When I plug in a flash drive, it gets mounted automatically in
> /media/102B-1B76, only the last nine characters are not always the
> same.  Since usually there is only one directory in /media I want a
> command that will cd to that directory.
> 
> I tried
> /media$ find . -mindepth 1 -type d -prune|sed 's:./::'|xargs cd
> but I get
> xargs: cd: No such file or directory
> however
> /media$ find . -mindepth 1 -type d -prune|sed 's:./::'
> returns
> 102B-1B76
> 
> I have also tried the -print0 option, but without further success.
> Any ideas?
> ...John

Perhaps you'd be happier looking up the UUID for the flash drive and
adding an auto-mount line into /etc/fstab?  Then you can mount it
anywhere you like and the directory will always be the same.  Just look
at the cdrom/dvd line for an example. Obviously, you'd want slightly
different options, since flash is rw, not ro and probably vfat.

I've never done this, but can't imagine it is too difficult.


More information about the Ale mailing list