#!/bin/bash # Program to output a system information page TITLE="System Information Report For $HOSTNAME" CURRENT_TIME=$(date +"%x %r %Z") TIME_STAMP="Generated $CURRENT_TIME, by $USER" report_uptime () { return } report_disk_space () { return } report_home_space () { return } cat << _EOF_ <HTML> <HEAD> <TITLE>$TITLE</TITLE> </HEAD> <BODY> <H1>$TITLE</H1> <P>$TIME_STAMP</P> $(report_uptime) $(report_disk_space) $(report_home_space) </BODY> </HTML> _EOF_
1 2 3 4 5 6 7 8 9 10 11 12 13
$ ./t.sh <HTML> <HEAD> <TITLE>System Information Report For hs-Z390-AORUS-PRO</TITLE> </HEAD> <BODY> <H1>System Information Report For hs-Z390-AORUS-PRO</H1> <P>Generated 2021年04月25日 下午 11时09分51秒 CST, by hs</P>
#!/bin/bash # test-file: Evaluate the status of a file FILE=~/.bashrc if [ -e "$FILE" ]; then if [ -f "$FILE" ]; then echo"$FILE is a regular file." fi if [ -d "$FILE" ]; then echo"$FILE is a directory." fi if [ -r "$FILE" ]; then echo"$FILE is readable." fi if [ -w "$FILE" ]; then echo"$FILE is writable." fi if [ -x "$FILE" ]; then echo"$FILE is executable/searchable." fi else echo"$FILE does not exist" exit 1 fi exit
1 2 3 4 5
$ chmod +x test-file.sh $ ./test-file.sh /home/hs/.bashrc is a regular file. /home/hs/.bashrc is readable. /home/hs/.bashrc is writable.