Cloud computing tutorial learning course syllabus courseware knowledge points on the shell:
There in the shell syntax color print fonts framework, often used to output an error message or require special display, which operate very practical, like me
In the preparation of the operation and maintenance are a tool, it can greatly enhance the program added to the list can be dominant.
Get and set the date
Usually when we writing the script, we hope after the script is finished, recorded this time to perform, and written to a log file so we can track every
The result of execution, but also help us analyze the number of calls the script.
The basic way to debug scripts
[root@bavdu shell_s]# vim color_daemon01.sh
#!/usr/bin/env bash
Font Color Code #: Reset = 0 = 31 Black Red Green = 30 = 32 H = 33 color = blue cyan 34 magenta 35 = 37 = 36 = white
The background color code #: Reset = 0 = 41 Black Red Green = 40 = 42 H = 43 color = blue cyan 44 magenta 45 = 47 = 46 = white
export green="this is a green."
printf "\e[1;31m $green \e[0m\n"
[root@bavdu shell_s]# sh color_daemon01.sh
this is a green -. This is the red
[root@bavdu shell_s]# vim date_daemon01.sh
#!/usr/bin/env bash
#
Author: bavdu
Email: [email protected]
Github: https://github.com/bavdu
Date: 2019//
printf "Hello world"
echo date +%Y-%m-%d_%k:%M:%S
>>/var/log/date_daemon01.log
[root@bavdu shell_s]# cat /var/log/date_daemon01.log
2018-12-27_ 6:34:45
[root@bavdu shell_s]# vim date_daemon01.sh
#!/usr/bin/env bash
#
Author: bavdu
Email: [email protected]
Github: https://github.com/bavdu
Date: 2019//
Printf "Hello world" # less deliberately wrote a letter
echo date +%Y-%m-%d_%k:%M:%S
>>/var/log/date_daemon01.log
[root@bavdu shell_s]# bash -x date_daemon01.sh
- rintf 'Hello world'
date_daemon05.sh: Line 8: rintf: command not found
++ date +%Y-%m-%d_%k:%M:%S
- echo 2018-12-27_ 6:38:14
[root@bavdu shell_s]#