how to select the last line of the shell output

后端 未结 3 408
甜味超标
甜味超标 2021-01-26 03:34

Hi I have a shell command like this.

s3=$(awk \'BEGIN{ print \"S3 bucket path\" }
 /Executing command\\(queryId/{ sub(/.*queryId=[^[:space:]]+: /,\"\"); q=$0 }
          


        
3条回答
  •  南笙
    南笙 (楼主)
    2021-01-26 04:14

    Hi you can do it just by adding echo $s3 | sed '$!d'

    s3=$(awk 'BEGIN{ print "S3 bucket path" }/Executing command\(queryId/{ sub(/.*queryId=[^[:space:]]+: /,""); q=$0 } /s3:\/\//{ print "," $10 }' OFS=',' hive-server2.log)
    
    echo $s3 | sed '$!d'
    

    It will simply print:-

    2018-02-21T18:05:34
    

    Hope this will help you.

提交回复
热议问题