How to print third column to last column?

前端 未结 19 2101
面向向阳花
面向向阳花 2020-11-28 18:44

I\'m trying to remove the first two columns (of which I\'m not interested in) from a DbgView log file. I can\'t seem to find an example that prints from column 3 onwards unt

19条回答
  •  生来不讨喜
    2020-11-28 19:01

    If you want to print the columns after the 3rd for example in the same line, you can use:

    awk '{for(i=3; i<=NF; ++i) printf "%s ", $i; print ""}'
    

    For example:

    Mar 09:39 20180301_123131.jpg
    Mar 13:28 20180301_124304.jpg
    Mar 13:35 20180301_124358.jpg
    Feb 09:45 Cisco_WebEx_Add-On.dmg
    Feb 12:49 Docker.dmg
    Feb 09:04 Grammarly.dmg
    Feb 09:20 Payslip 10459 %2828-02-2018%29.pdf
    

    It will print:

    20180301_123131.jpg
    20180301_124304.jpg
    20180301_124358.jpg
    Cisco_WebEx_Add-On.dmg
    Docker.dmg
    Grammarly.dmg
    Payslip 10459 %2828-02-2018%29.pdf
    

    As we can see, the payslip even with space, shows in the correct line.

提交回复
热议问题