遍历加数字

2018-08-02  本文已影响3人  夜空最亮的9星
#!/bin/bash
sum=0
while read line
do
    let sum=sum+1
    echo $sum,$line >> state_num.txt
done < state.txt
    #!/bin/sh
    num=0
    cat test.txt | while read line
    do
            echo $line
            num=`expr $num + 1`
    done
    echo $num
[root@node1 ~]# awk '{print NR,$1}' tableName.txt >>table2.txt
[root@node1 ~]# cat table2.txt 
1 hello
2 hadoop
3 spark
4 mapreduce
5 storm
6 python
7 
[root@node1 ~]# 

上一篇下一篇

猜你喜欢

热点阅读