11.04.2013 Views

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appen<strong>di</strong>ce A. Script aggiuntivi<br />

#<br />

# Written by Phil Braham - Realtime Software Pty Ltd<br />

# (realtime@mpx.com.au)<br />

# Please send any suggestions or enhancements to the author (also at<br />

# phil@braham.net)<br />

#<br />

############################################################################<br />

cd_hm ()<br />

{<br />

${PRINTF} "%s" "cd [<strong>di</strong>r] [0-9] [@[s|h] [-g []] [-d] [-D] [-r] [<strong>di</strong>r|0-9] [-<br />

[-s] [-S] [-u] [-U] [-f] [-F] [-h] [-H] [-v]<br />

Go to <strong>di</strong>rectory<br />

0-n Goto previous <strong>di</strong>rectory (0 is previous, 1 is last but 1 etc)<br />

n is up to max history (default is 50)<br />

@ List history and special entries<br />

@h List history entries<br />

@s List special entries<br />

-g [] Go to literal name (bypass special names)<br />

This is to allow access to <strong>di</strong>rs called ’0’,’1’,’-h’ etc<br />

-d Change default action - verbose. (See note)<br />

-D Change default action - silent. (See note)<br />

-s Go to the special entry *<br />

-S Go to the special entry and replace it with the current <strong>di</strong>r*<br />

-r [] Go to <strong>di</strong>rectory and then put it on special entry *<br />

-R [] Go to <strong>di</strong>rectory and put current <strong>di</strong>r on special entry *<br />

-a Alternative suggested <strong>di</strong>rectory. See note below.<br />

-f [] File entries to .<br />

-u [] Update entries from .<br />

If no filename supplied then default file (${CDPath}${2:-"$CDFile"}) is used<br />

-F and -U are silent versions<br />

-v Print version number<br />

-h Help<br />

-H Detailed help<br />

*The special entries (0 - 9) are held until log off, replaced by another entry<br />

or updated with the -u command<br />

Alternative suggested <strong>di</strong>rectories:<br />

If a <strong>di</strong>rectory is not found then CD will suggest any possibilities. These are<br />

<strong>di</strong>rectories starting with the same letters and if any are found they are listed<br />

prefixed with -a where is a number.<br />

It’s possible to go to the <strong>di</strong>rectory by entering cd -a on the command line.<br />

The <strong>di</strong>rectory for -r or -R may be a number. For example:<br />

$ cd -r3 4 Go to history entry 4 and put it on special entry 3<br />

$ cd -R3 4 Put current <strong>di</strong>r on the special entry 3 and go to history entry 4<br />

$ cd -s3 Go to special entry 3<br />

Note that commands R,r,S and s may be used without a number and refer to 0:<br />

$ cd -s Go to special entry 0<br />

$ cd -S Go to special entry 0 and make special entry 0 current <strong>di</strong>r<br />

$ cd -r 1 Go to history entry 1 and put it on special entry 0<br />

748

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!