readded udpated scripts directory

This commit is contained in:
tomit4 2022-06-09 12:59:03 -07:00
parent cd053a412a
commit f3117c81d9
84 changed files with 3210 additions and 0 deletions

15
scripts/trap.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
touch temp.txt
# trap is a powerful command that allows us to chain an execution of commands AFTER a particular command is executed.
# to demonstrate this, we tell trap to hold onto the 'rm temp.txt' command, which removes the temp.txt file we just created above, note however, that it will only do that upon exit, as specified below.
trap 'rm temp.txt' err exit
# Now we will list all files in our directory to show that indeed, temp.txt still exists...
ls
# however, by running this program, we will then exit this shell, and thusly invoke the trap command above, if we invoke ls after invoking this shell script, you will notice that temp.txt no longer exists.
exit