1: Using the Linux command line number where the hollow line query file
[yege@hadoop102 datas]$ awk '/^$/{print NR}' sed.txt
5
2: There is a file chengji.txt reads as follows:
张三 40
李四 50
王五 60
Using Linux commands and calculates and outputs the second column
[yege@hadoop102 datas]$ cat chengji.txt | awk -F " " '{sum+=$2} END{print sum}'
150
3, Shell script how to check whether a file exists? What happens if the process does not exist?
#!/bin/bash
if [ -f file.txt ]; then
echo "文件存在!"
else
echo "文件不存在!"
fi
4, with a shell script to write a sort of text in test.txt disorderly one digital, and output and
9
8
7
6
5
4
3
2
10
1
[root@CentOS6-2 ~]# sort -n test.txt|awk '{a+=$0;print $0}END{print "SUM="a}'
5, please write shell scripts to find the current folder (/ home) all of the text file contains a file name has characters "shen" of
[yege@hadoop102 datas]$ grep -r "shen" /home | cut -d ":" -f 1