27.08.2015 Views

Advanced Bash−Scripting Guide

Advanced Bash-Scripting Guide - Nicku.org

Advanced Bash-Scripting Guide - Nicku.org

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Note: 'mount −l' does return the label and could return the UUID<br />

[3] Maximum length of filenames<br />

[4] Filesystem type<br />

[5] Total blocks in the filesystem<br />

[6] Free blocks<br />

[7] Free blocks for non−root user(s)<br />

[8] Block size of the filesystem<br />

[9] Total inodes<br />

[10] Free inodes<br />

−*−*− Per:<br />

Return code: 0<br />

Size of array: 11<br />

Contents of array<br />

Element 0: /home/mszick<br />

Element 1: 0<br />

Element 2: 0<br />

Element 3: 255<br />

Element 4: ef53<br />

Element 5: 2581445<br />

Element 6: 2277180<br />

Element 7: 2146050<br />

Element 8: 4096<br />

Element 9: 1311552<br />

Element 10: 1276425<br />

StatFieldsDoc<br />

<strong>Advanced</strong> <strong>Bash−Scripting</strong> <strong>Guide</strong><br />

# LocateFile [−l] FileName Location−Array−Name<br />

# LocateFile [−l] −of FileName Location−Array−FileName<br />

LocateFile()<br />

{<br />

local −a LOC LOC1 LOC2<br />

local lk="" of=0<br />

case "$#" in<br />

0) return 1 ;;<br />

1) return 1 ;;<br />

2) : ;;<br />

*) while (( "$#" > 2 ))<br />

do<br />

case "$1" in<br />

−l) lk=−1 ;;<br />

−of) of=1 ;;<br />

*) return 1 ;;<br />

esac<br />

shift<br />

done ;;<br />

esac<br />

# More Sanscrit−2.0.5<br />

# LOC1=( $(stat −t $lk $1) )<br />

# LOC2=( $(stat −tf $lk $1) )<br />

# Uncomment above two lines if system has "stat" command installed.<br />

LOC=( ${LOC1[@]:0:1} ${LOC1[@]:3:11}<br />

${LOC2[@]:1:2} ${LOC2[@]:4:1} )<br />

case "$of" in<br />

0) eval $2=\( \"\$\{LOC\[@\]\}\" \) ;;<br />

Appendix A. Contributed Scripts 403

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

Saved successfully!

Ooh no, something went wrong!