24.07.2018 Views

Bash-Beginners-Guide

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

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

touch pic-`date +%s`.jpg<br />

sleep 300<br />

done<br />

Note the use of the date command to generate all kinds of file and directory names. See the man page for<br />

more.<br />

Use the system<br />

<strong>Bash</strong> <strong>Guide</strong> for <strong>Beginners</strong><br />

The previous example is for the sake of demonstration. Regular checks can easily be achieved using the<br />

system's cron facility. Do not forget to redirect output and errors when using scripts that are executed<br />

from your crontab!<br />

9.2.2.3. Using keyboard input to control the while loop<br />

This script can be interrupted by the user when a Ctrl+C sequence is entered:<br />

#!/bin/bash<br />

# This script provides wisdom<br />

FORTUNE=/usr/games/fortune<br />

while true; do<br />

echo "On which topic do you want advice?"<br />

cat

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

Saved successfully!

Ooh no, something went wrong!