First type:
#!/bin/bash service vsftpd start &>/dev/null if
[$-eq 0]
Then
echo "FTP is start"
Else
Service VSFTPD Start
Fi
The second type:
#!/bin/bash read-p "Input your file name" file_name
If [D-$file _name]//To determine whether the directory
Then
echo "This file is directory!"
Elif [-F $file _name]//is a file
Then
echo "This file is file"
elif [-C $file _name-o-b $file _name]//is a character device or block device, which is OK
Then
Echo ' This is block file ' else echo ' This file unknown '
Fi
[Root@redhat shellscripts]# LL/DEV/SDA BRW-RW----. 1 root Disk 8, 0 June 1 10:05/DEV/SDA
[Root@redhat shellscripts]# Ll/dev/tty crw-rw-rw-. 1 root TTY 5, 0 June 1 10:05/dev/tty
This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/
The third type:
#!/bin/bash
If [$#-ne 2]
Then
echo "Not Enough parameters"
Exit 0///If not 2, jump out of the loop
Fi
If [$1-eq $]
Then
echo "$ = $"
elif [$1-lt $]
Then
echo "$ < $"
Fi
Results of execution:
[Root@redhat shellscripts]# sh test.sh 1 1 1 = 1
[Root@redhat shellscripts]# sh test.sh 1 2 1 < 2 ~