Formatting display of of `set -v` output
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
From the description of set
in the bash
man
page:
-v Print shell input lines as they are read.
Thus, the following example script:
#!/usr/bin/env bash
# setv.sh
set -v
foo=bar
echo $foo
Generates output:
foo=bar
echo $foo
bar
Is there a way for it to prepend some string, say "+ " to each line, so as to clearly indicate which line is a line from the script, and which line is output of a line of from the script. Using the above example, the desired output would be:
+ foo=bar
+ echo $foo
bar
bash set
add a comment |Â
up vote
3
down vote
favorite
From the description of set
in the bash
man
page:
-v Print shell input lines as they are read.
Thus, the following example script:
#!/usr/bin/env bash
# setv.sh
set -v
foo=bar
echo $foo
Generates output:
foo=bar
echo $foo
bar
Is there a way for it to prepend some string, say "+ " to each line, so as to clearly indicate which line is a line from the script, and which line is output of a line of from the script. Using the above example, the desired output would be:
+ foo=bar
+ echo $foo
bar
bash set
What do you mean when you say "The output looks like"? What command did you execute to generate that undesirable output?
â user1404316
Mar 15 at 20:11
I think I now understand what you are looking for. I'll try to edit your question to make it clearer.
â user1404316
Mar 15 at 20:21
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
From the description of set
in the bash
man
page:
-v Print shell input lines as they are read.
Thus, the following example script:
#!/usr/bin/env bash
# setv.sh
set -v
foo=bar
echo $foo
Generates output:
foo=bar
echo $foo
bar
Is there a way for it to prepend some string, say "+ " to each line, so as to clearly indicate which line is a line from the script, and which line is output of a line of from the script. Using the above example, the desired output would be:
+ foo=bar
+ echo $foo
bar
bash set
From the description of set
in the bash
man
page:
-v Print shell input lines as they are read.
Thus, the following example script:
#!/usr/bin/env bash
# setv.sh
set -v
foo=bar
echo $foo
Generates output:
foo=bar
echo $foo
bar
Is there a way for it to prepend some string, say "+ " to each line, so as to clearly indicate which line is a line from the script, and which line is output of a line of from the script. Using the above example, the desired output would be:
+ foo=bar
+ echo $foo
bar
bash set
edited Mar 15 at 22:04
user1404316
2,314520
2,314520
asked Mar 15 at 20:07
mbigras
5822522
5822522
What do you mean when you say "The output looks like"? What command did you execute to generate that undesirable output?
â user1404316
Mar 15 at 20:11
I think I now understand what you are looking for. I'll try to edit your question to make it clearer.
â user1404316
Mar 15 at 20:21
add a comment |Â
What do you mean when you say "The output looks like"? What command did you execute to generate that undesirable output?
â user1404316
Mar 15 at 20:11
I think I now understand what you are looking for. I'll try to edit your question to make it clearer.
â user1404316
Mar 15 at 20:21
What do you mean when you say "The output looks like"? What command did you execute to generate that undesirable output?
â user1404316
Mar 15 at 20:11
What do you mean when you say "The output looks like"? What command did you execute to generate that undesirable output?
â user1404316
Mar 15 at 20:11
I think I now understand what you are looking for. I'll try to edit your question to make it clearer.
â user1404316
Mar 15 at 20:21
I think I now understand what you are looking for. I'll try to edit your question to make it clearer.
â user1404316
Mar 15 at 20:21
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
To get that kind of output you could use $BASH_COMMAND
e.g. add
trap 'printf "%s %sn" + "$BASH_COMMAND" >&2' DEBUG
instead of set -x/v
at the top your script.
You would probably want to print that on stderr. The OP might also wantset -o functrace
â Stéphane Chazelas
Mar 15 at 21:33
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
To get that kind of output you could use $BASH_COMMAND
e.g. add
trap 'printf "%s %sn" + "$BASH_COMMAND" >&2' DEBUG
instead of set -x/v
at the top your script.
You would probably want to print that on stderr. The OP might also wantset -o functrace
â Stéphane Chazelas
Mar 15 at 21:33
add a comment |Â
up vote
3
down vote
accepted
To get that kind of output you could use $BASH_COMMAND
e.g. add
trap 'printf "%s %sn" + "$BASH_COMMAND" >&2' DEBUG
instead of set -x/v
at the top your script.
You would probably want to print that on stderr. The OP might also wantset -o functrace
â Stéphane Chazelas
Mar 15 at 21:33
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
To get that kind of output you could use $BASH_COMMAND
e.g. add
trap 'printf "%s %sn" + "$BASH_COMMAND" >&2' DEBUG
instead of set -x/v
at the top your script.
To get that kind of output you could use $BASH_COMMAND
e.g. add
trap 'printf "%s %sn" + "$BASH_COMMAND" >&2' DEBUG
instead of set -x/v
at the top your script.
edited Mar 15 at 21:37
answered Mar 15 at 21:08
don_crissti
46.4k15123153
46.4k15123153
You would probably want to print that on stderr. The OP might also wantset -o functrace
â Stéphane Chazelas
Mar 15 at 21:33
add a comment |Â
You would probably want to print that on stderr. The OP might also wantset -o functrace
â Stéphane Chazelas
Mar 15 at 21:33
You would probably want to print that on stderr. The OP might also want
set -o functrace
â Stéphane Chazelas
Mar 15 at 21:33
You would probably want to print that on stderr. The OP might also want
set -o functrace
â Stéphane Chazelas
Mar 15 at 21:33
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430480%2fformatting-display-of-of-set-v-output%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
What do you mean when you say "The output looks like"? What command did you execute to generate that undesirable output?
â user1404316
Mar 15 at 20:11
I think I now understand what you are looking for. I'll try to edit your question to make it clearer.
â user1404316
Mar 15 at 20:21