Linux character in command
* matches zeor or more characters
? matches any single character
[a-z] matches a range of characters
Example: text[1-2].txt
[^a-z] matches all except the range
Example: text[^1-2].txt
cd ~<username>: go to the home directory of the user(only can be applied by root)
cd ~: go to the home directory of current user
use {} in command
Example:
#touch {a,b}
the command will create a,b two files
#touch a{a,b}
the command will create aa,ab two files
#touch {a,b}.{1,2}
the command will create a.1,a.2,b.1,b.2 four files
Comand inside another command
Example:
#echo "Hostname:`hostname`" or echo "Hostname:$(hostname)"
Variable Math in command
Example:
#a=3
#echo $a
3
#b=5
#echo $b
5
#echo $[ $a + $b ]
8
#echo $[ $a ** $b ] (**: ^)
243
Variable change to normal string: \ or double quote "" or single quote''
Example:
#echo "Your cost is \$5.00"
Your cost is $5.00
Exception
double quote no use for $, \, `, !
\: use to input command in next line
Example
#ls \
>-l
Comments
Post a Comment