Echo command, and then run it? (Like make)

前端 未结 6 1518
走了就别回头了
走了就别回头了 2021-02-02 12:49

Is there some way to get bash into a sort of verbose mode where, such that, when it\'s running a shell script, it echoes out the command it\'s going to run before running it? T

6条回答
  •  心在旅途
    2021-02-02 13:46

    For extra timestamps and I/O info, consider the annotate-output command from Debian's devscripts package:

    annotate-output echo hello
    

    Output:

    13:19:08 I: Started echo hello
    13:19:08 O: hello
    13:19:08 I: Finished with exitcode 0
    

    Now look for a file that doesn't exist, and note the E: for STDERR output:

    annotate-output ls nosuchfile
    

    Output:

    13:19:48 I: Started ls nosuchfile
    13:19:48 E: ls: cannot access 'nosuchfile': No such file or directory
    13:19:48 I: Finished with exitcode 2
    

提交回复
热议问题