diff options
author | Sachin Divekar <ssd532@gmail.com> | 2016-06-26 18:08:05 +0530 |
---|---|---|
committer | ven <vendethiel@hotmail.fr> | 2016-06-26 14:38:05 +0200 |
commit | d1216a4253c1b03641c10b171030d04227ad8408 (patch) | |
tree | f131979ad24915625010a8fad66491bbe1130450 /bash.html.markdown | |
parent | d4aa031d55e03a08f92fd2e3c407655eaf3ef4f2 (diff) |
Add an example of trap command (#1826)
* Begin writing document for PCRE
Started writing learnxinyminutes document for PCRE to cover general purpose regular expressions.
Added introduction and a couple of details.
* Change introductory example for regex
The old example was incorrect. It's replaced with a simple one.
* Add some more introductory text
* Add first example
* Added more example and a table for proper formatting
* Add few more examples
* Formatting
* Improve example
* Edit description of character classes
* Add a way to test regex
Add https://regex101.com/ web application to test the regex provided in example.
* Add example of trap command
trap is a very important command to intercept a fatal signal, perform cleanup, and then exit gracefully. It needs an entry in this document.
Here a simple and most common example of using trap command i.e. cleanup upon receiving signal is added.
* Revert "Add example of trap command"
* Add an example of trap command
`trap` is a very important command to intercept a fatal signal, perform cleanup, and then exit gracefully. It needs an entry in this document.
Here a simple and most common example of using `trap` command i.e. cleanup upon receiving signal is added.
Diffstat (limited to 'bash.html.markdown')
-rw-r--r-- | bash.html.markdown | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/bash.html.markdown b/bash.html.markdown index 02d7f31e..c2c3e3f1 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -272,6 +272,9 @@ grep -c "^foo.*bar$" file.txt # and not the regex, use fgrep (or grep -F) fgrep "foobar" file.txt +# trap command allows you to execute a command when a signal is received by your script. +# Here trap command will execute rm if any one of the three listed signals is received. +trap "rm $TEMP_FILE; exit" SIGHUP SIGINT SIGTERM # Read Bash shell builtins documentation with the bash 'help' builtin: help |