美文网首页
遍历加数字

遍历加数字

作者: 夜空最亮的9星 | 来源:发表于2018-08-02 20:21 被阅读3次
    #!/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 ~]# 
    
    

    相关文章

      网友评论

          本文标题:遍历加数字

          本文链接:https://www.haomeiwen.com/subject/xhosvftx.html