Linux Command
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| pwd cd / ls -l
mkdir rmdir
touch filename cp lab1/original lab2/dup mv lab1/a.txt lab2/ mv lab1/a.txt lab1/newname.txt rm a.txt
cat a.txt less a.txt diff a.txt b.txt head a.txt -n 5 tail a.txt -n 5 wc -w a.txt
xterm clear
chmod u-r a.txt chmod u+r a.txt chmod go-r a.txt chmod 444 a.txt
grep searchword a.txt grep ^Hello a.txt grep searchword a.txt | wc
ls > a.txt
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| echo $USER cd $HOME cd ~ echo $PATH
PATH=$PATH:/home/ubuntu/dir
zip hello.zip * zip hello.zip -r hello/* unzip hello.zip
tar -zcvf hello.tar.gz hello/ tar -zxvf hello.tar.gz
wget url -O newname
|
Shell Script
脚本test.sh
就是一坨命令,执行脚本就是按照顺序执行这些命令。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| a=10 echo $a c=`expr $a + $b` c=`expr $a \* $b`
if [ $a -gt $b ] then echo $a else echo $b fi
for x in 1 2 3 do echo $x done
x=1 while [ $x -le 10] do echo $x x=`expr $x + 1` done
a="hello" b="world"
read a read b c=`expr $a + $b` echo $a + $b = $c
if [ $a = $b ] if [ $a != $b ] str3="$str1$str2" if [ -z $str1 ]
arr=(1 2 3) echo ${arr[1]} for i in ${arr[@]} do echo $i done
|