【问题标题】:How append the username into the file name如何将用户名附加到文件名中
【发布时间】:2018-09-21 21:28:38
【问题描述】:

我有这个脚本,

find -iname \*.${EXT} -print0 | xargs -0 ls -l --time-style="+%b %Y" | awk '{print $NF,$3,$5,$6,$7}' OFS="\t" > ${EXT}.txt
awk -vextension="${EXT}" -vfiletype="${TYPE}" -vcompress="${COMP}" -vOFS="\t" '{print $0, ext, filetype, compress}' < ${EXT}.txt >> all.txt

我想更改脚本以自动将运行此脚本的用户的用户名附加到文件中,例如“Jason_all.txt”作为最终输出。

【问题讨论】:

    标签: linux bash shell command-line filenames


    【解决方案1】:

    简单:

    find -iname \*.${EXT} -print0 | xargs -0 ls -l --time-style="+%b %Y" | awk '{print $NF,$3,$5,$6,$7}' OFS="\t" > ${EXT}.txt
    awk -vextension="${EXT}" -vfiletype="${TYPE}" -vcompress="${COMP}" -vOFS="\t" '{print $0, ext, filetype, compress}' < ${EXT}.txt >> "${USER}_all.txt"
    

    最好将此 sn-p 编辑为 not parsing ls output

    改为检查man find | less +/'printf format'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-20
      • 1970-01-01
      • 1970-01-01
      • 2012-04-20
      • 2021-08-21
      • 2017-09-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多