for循环语句
[root@kong]# more text.txt
for循环语句
while循环语句 while循环语句
until循环语句
[root@kong]# vi for.sh
#!/bin/bash
for line in $(cat text.txt)
do
echo $line
done
[root@kong]# sh for.sh
for循环语句
while循环语句
while循环语句
until循环语句
while循环语句
[root@kong]# more text.txt
for循环语句
while循环语句 while循环语句
until循环语句
[root@kong]# vi while_1.sh
#!/bin/bash
while read line
do
echo $line
done < text.txt
[root@kong]# sh while_1.sh
for循环语句
while循环语句 while循环语句
until循环语句
[root@kong]# more text.txt
for循环语句
while循环语句 while循环语句
until循环语句
[root@kong]# vi while_2.sh
#!/bin/bash
cat text.txt | while read line
do
echo $line
done
[root@kong]# sh while_2.sh
for循环语句
while循环语句 while循环语句
until循环语句
分隔符
[root@localhost loop]# more text.txt
16 E @ f O P Z
15 D @ g N Q Y
14 C @ h M S
13 B @ i L U X
12 A @ j K V W
[root@localhost loop]# sed -n l text.txt
16 E\t@ f O \tP\tZ$
15 D\t@ g N\t\tQ\tY$
14 C\t@ h M\t\tS\t\t$
13 B\t@ i L\t\tU\tX$
12 A\t@ j K\tV\t\tW$
[root@localhost loop]# awk -F " " '{print $1,$2,$3,$4,$5,$6,$7}' text.txt
16 E @ f O P Z
15 D @ g N Q Y
14 C @ h M S
13 B @ i L U X
12 A @ j K V W
[root@localhost loop]# awk -F "@" '{print $1,$2,$3,$4,$5,$6,$7}' text.txt
16 E f O P Z
15 D g N Q Y
14 C h M S
13 B i L U X
12 A j K V W
[root@localhost loop]# cat text.txt|tr "\t" ","
16 E,@ f O ,P,Z
15 D,@ g N,,Q,Y
14 C,@ h M,,S,,
13 B,@ i L,,U,X
12 A,@ j K,V,,W
[root@localhost loop]# awk 'BEGIN{ FS=" ";OFS="," }{ print $1,$2,$3,$4,$5,$6,$7 }' text.txt
16,E,@,f,O,P,Z
15,D,@,g,N,Q,Y
14,C,@,h,M,S,
13,B,@,i,L,U,X
12,A,@,j,K,V,W
[root@localhost loop]# awk -F " " '{if($1~/^16/) print $1,$2,$3,$4,$5,$6,$7}' text.txt
16 E @ f O P Z
[root@localhost loop]#