trap 的初步应用
#!/bin/bash
trap 'rm -f fred1' INT
touch fred1
echo "Print Ctrl + C "
while [ -f fred1 ]; do
echo "File exist!"
sleep 1
done
echo "the file no longer exists"
trap INT
echo create file
echo > fred1
while [ -f fred1 ]; do
echo "File exists too!"
sleep 1
done
echo we never get here
exit 0
unset 的初步应用
#!/bin/bash
foo="Hello World!"
echo $foo
unset foo
echo $foo
exit 0