Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7399359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:03:03+00:00 2026-05-29T04:03:03+00:00

If I enter bash -x option, it will show all the line. But the

  • 0

If I enter bash -x option, it will show all the line. But the script will execute normally.

How can I execute line by line? Than I can see if it do the correct thing, or I abort and fix the bug. The same effect is put a read in every line.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:03:04+00:00Added an answer on May 29, 2026 at 4:03 am

    You don’t need to put a read in everyline, just add a trap like the following into your bash script, it has the effect you want, eg.

    #!/usr/bin/env bash
    set -x
    trap read debug
    
    < YOUR CODE HERE >
    

    Works, just tested it with bash v4.2.8 and v3.2.25.


    IMPROVED VERSION

    If your script is reading content from files, the above listed will not work. A workaround could look like the following example.

    #!/usr/bin/env bash
    echo "Press CTRL+C to proceed."
    trap "pkill -f 'sleep 1h'" INT
    trap "set +x ; sleep 1h ; set -x" DEBUG
    
    < YOUR CODE HERE >
    

    To stop the script you would have to kill it from another shell in this case.


    ALTERNATIVE1

    If you simply want to wait a few seconds before proceeding to the next command in your script the following example could work for you.

    #!/usr/bin/env bash
    trap "set +x; sleep 5; set -x" DEBUG
    
    < YOUR CODE HERE >
    

    I’m adding set +x and set -x within the trap command to make the output more readable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to execute a particular bash function when I enter a new directory.
i have the following shell script- #!/bin/bash echo enter the full path of script;
I need to execute a Bash command in a Ruby script. There are about
I want to write a python script (Yes not Bash) that will use flac
I am currently using Instruments via a bash script to initiate the command-line interface
When I enter the following (BASH): rdesktop -r disk:bacon=~/bacon host It does not expand
enter code here Hi All, I have a simple windows service application that connects
enter code hereHiya, so far I didn't use JSP at all and I find
When I enter an object into the DB with Linq-to-SQL can I get the
In Firefox you can enter the following into the awesome bar and hit enter:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.