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...

Create successful ePaper yourself

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

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

fi<br />

done < "$Filename" > "$Savefile" # Redirects stdin to file $Filename,<br />

# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ and saves it to backup file.<br />

exit 0<br />

Example 16−9. Redirected if/then test<br />

#!/bin/bash<br />

if [ −z "$1" ]<br />

then<br />

Filename=names.data<br />

else<br />

Filename=$1<br />

fi<br />

# Default, if no filename specified.<br />

TRUE=1<br />

if [ "$TRUE" ] # if true and if : also work.<br />

then<br />

read name<br />

echo $name<br />

fi

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

Saved successfully!

Ooh no, something went wrong!