Results 1 to 5 of 5

Thread: [SOLVED] Displaying shell script lines when executing

  1. #1
    Join Date
    Apr 2008
    Location
    Show me state, USA
    Beans
    162
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    [SOLVED] Displaying shell script lines when executing

    Is there a flag/switch that you can turn on in a shell script that will display the lines of the script as they are being executing?
    When executing a script, I'd like to see the line/command that is being executed on stdout, followed by the output from that command.

    In other words how do you debug a script?

  2. #2
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: Displaying shell script lines when executing

    never tried it but how about:
    Code:
    sh -v scrip.sh
    -v is normally verbose mode... not sure if that works but might be worth a try.

  3. #3
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Displaying shell script lines when executing

    You also can set the verbose mode in the script:
    #!/bin/bash -v
    ...
    commands....

  4. #4
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: Displaying shell script lines when executing

    I knew there must be a way

  5. #5
    Join Date
    Apr 2008
    Location
    Show me state, USA
    Beans
    162
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: Displaying shell script lines when executing

    thanks to both of you.

    Also the -x option shows me the line after variable substitution has taken place!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •