Any way to have a “verbose mode” or “debug mode” with sed?
Clash Royale CLAN TAG#URR8PPP
Is there a way to make gnu sed
be verbose about what is run and what is done ?
I'd like to have something like a "debug mode" so that I can see - for each line of input - the content of the hold space and pattern space before and after the script is run etc.
sed debugging gnu
add a comment |
Is there a way to make gnu sed
be verbose about what is run and what is done ?
I'd like to have something like a "debug mode" so that I can see - for each line of input - the content of the hold space and pattern space before and after the script is run etc.
sed debugging gnu
Isl;x;l;x;
at the start & end of the program adequate?
– Michael Homer
Jan 6 at 19:36
1
It looks like GNUsed
gained a--debug
feature last summer (version 4.6).
– fra-san
Jan 6 at 19:56
add a comment |
Is there a way to make gnu sed
be verbose about what is run and what is done ?
I'd like to have something like a "debug mode" so that I can see - for each line of input - the content of the hold space and pattern space before and after the script is run etc.
sed debugging gnu
Is there a way to make gnu sed
be verbose about what is run and what is done ?
I'd like to have something like a "debug mode" so that I can see - for each line of input - the content of the hold space and pattern space before and after the script is run etc.
sed debugging gnu
sed debugging gnu
edited Jan 6 at 20:14
Jeff Schaller
39.7k1054126
39.7k1054126
asked Jan 6 at 19:19
don_crisstidon_crissti
50.3k15134162
50.3k15134162
Isl;x;l;x;
at the start & end of the program adequate?
– Michael Homer
Jan 6 at 19:36
1
It looks like GNUsed
gained a--debug
feature last summer (version 4.6).
– fra-san
Jan 6 at 19:56
add a comment |
Isl;x;l;x;
at the start & end of the program adequate?
– Michael Homer
Jan 6 at 19:36
1
It looks like GNUsed
gained a--debug
feature last summer (version 4.6).
– fra-san
Jan 6 at 19:56
Is
l;x;l;x;
at the start & end of the program adequate?– Michael Homer
Jan 6 at 19:36
Is
l;x;l;x;
at the start & end of the program adequate?– Michael Homer
Jan 6 at 19:36
1
1
It looks like GNU
sed
gained a --debug
feature last summer (version 4.6).– fra-san
Jan 6 at 19:56
It looks like GNU
sed
gained a --debug
feature last summer (version 4.6).– fra-san
Jan 6 at 19:56
add a comment |
1 Answer
1
active
oldest
votes
As fra-san mentioned, GNU sed
introduced a --debug
option which does pretty much what you’re looking for, in version 4.6; so e.g if you run:
printf '%sn' one two | sed --debug 'H;1h;$x;$s/n/_/g'
the output is
SED PROGRAM:
H
1 h
$ x
$ s/n/_/g
INPUT: 'STDIN' line 1
PATTERN: one
COMMAND: H
HOLD: none
COMMAND: 1 h
HOLD: one
COMMAND: $ x
COMMAND: $ s/n/_/g
END-OF-CYCLE:
one
INPUT: 'STDIN' line 2
PATTERN: two
COMMAND: H
HOLD: onentwo
COMMAND: 1 h
COMMAND: $ x
PATTERN: onentwo
HOLD: two
COMMAND: $ s/n/_/g
MATCHED REGEX REGISTERS
regex[0] = 3-4 '
'
PATTERN: one_two
END-OF-CYCLE:
one_two
I don’t know what distribution you use, but it’s not available yet in Debian, Ubuntu, or Fedora; it will be included in the next releases of Debian (10) and Ubuntu (19.04).
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492871%2fany-way-to-have-a-verbose-mode-or-debug-mode-with-sed%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As fra-san mentioned, GNU sed
introduced a --debug
option which does pretty much what you’re looking for, in version 4.6; so e.g if you run:
printf '%sn' one two | sed --debug 'H;1h;$x;$s/n/_/g'
the output is
SED PROGRAM:
H
1 h
$ x
$ s/n/_/g
INPUT: 'STDIN' line 1
PATTERN: one
COMMAND: H
HOLD: none
COMMAND: 1 h
HOLD: one
COMMAND: $ x
COMMAND: $ s/n/_/g
END-OF-CYCLE:
one
INPUT: 'STDIN' line 2
PATTERN: two
COMMAND: H
HOLD: onentwo
COMMAND: 1 h
COMMAND: $ x
PATTERN: onentwo
HOLD: two
COMMAND: $ s/n/_/g
MATCHED REGEX REGISTERS
regex[0] = 3-4 '
'
PATTERN: one_two
END-OF-CYCLE:
one_two
I don’t know what distribution you use, but it’s not available yet in Debian, Ubuntu, or Fedora; it will be included in the next releases of Debian (10) and Ubuntu (19.04).
add a comment |
As fra-san mentioned, GNU sed
introduced a --debug
option which does pretty much what you’re looking for, in version 4.6; so e.g if you run:
printf '%sn' one two | sed --debug 'H;1h;$x;$s/n/_/g'
the output is
SED PROGRAM:
H
1 h
$ x
$ s/n/_/g
INPUT: 'STDIN' line 1
PATTERN: one
COMMAND: H
HOLD: none
COMMAND: 1 h
HOLD: one
COMMAND: $ x
COMMAND: $ s/n/_/g
END-OF-CYCLE:
one
INPUT: 'STDIN' line 2
PATTERN: two
COMMAND: H
HOLD: onentwo
COMMAND: 1 h
COMMAND: $ x
PATTERN: onentwo
HOLD: two
COMMAND: $ s/n/_/g
MATCHED REGEX REGISTERS
regex[0] = 3-4 '
'
PATTERN: one_two
END-OF-CYCLE:
one_two
I don’t know what distribution you use, but it’s not available yet in Debian, Ubuntu, or Fedora; it will be included in the next releases of Debian (10) and Ubuntu (19.04).
add a comment |
As fra-san mentioned, GNU sed
introduced a --debug
option which does pretty much what you’re looking for, in version 4.6; so e.g if you run:
printf '%sn' one two | sed --debug 'H;1h;$x;$s/n/_/g'
the output is
SED PROGRAM:
H
1 h
$ x
$ s/n/_/g
INPUT: 'STDIN' line 1
PATTERN: one
COMMAND: H
HOLD: none
COMMAND: 1 h
HOLD: one
COMMAND: $ x
COMMAND: $ s/n/_/g
END-OF-CYCLE:
one
INPUT: 'STDIN' line 2
PATTERN: two
COMMAND: H
HOLD: onentwo
COMMAND: 1 h
COMMAND: $ x
PATTERN: onentwo
HOLD: two
COMMAND: $ s/n/_/g
MATCHED REGEX REGISTERS
regex[0] = 3-4 '
'
PATTERN: one_two
END-OF-CYCLE:
one_two
I don’t know what distribution you use, but it’s not available yet in Debian, Ubuntu, or Fedora; it will be included in the next releases of Debian (10) and Ubuntu (19.04).
As fra-san mentioned, GNU sed
introduced a --debug
option which does pretty much what you’re looking for, in version 4.6; so e.g if you run:
printf '%sn' one two | sed --debug 'H;1h;$x;$s/n/_/g'
the output is
SED PROGRAM:
H
1 h
$ x
$ s/n/_/g
INPUT: 'STDIN' line 1
PATTERN: one
COMMAND: H
HOLD: none
COMMAND: 1 h
HOLD: one
COMMAND: $ x
COMMAND: $ s/n/_/g
END-OF-CYCLE:
one
INPUT: 'STDIN' line 2
PATTERN: two
COMMAND: H
HOLD: onentwo
COMMAND: 1 h
COMMAND: $ x
PATTERN: onentwo
HOLD: two
COMMAND: $ s/n/_/g
MATCHED REGEX REGISTERS
regex[0] = 3-4 '
'
PATTERN: one_two
END-OF-CYCLE:
one_two
I don’t know what distribution you use, but it’s not available yet in Debian, Ubuntu, or Fedora; it will be included in the next releases of Debian (10) and Ubuntu (19.04).
edited Jan 6 at 22:18
don_crissti
50.3k15134162
50.3k15134162
answered Jan 6 at 22:09
Stephen KittStephen Kitt
167k24376454
167k24376454
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492871%2fany-way-to-have-a-verbose-mode-or-debug-mode-with-sed%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is
l;x;l;x;
at the start & end of the program adequate?– Michael Homer
Jan 6 at 19:36
1
It looks like GNU
sed
gained a--debug
feature last summer (version 4.6).– fra-san
Jan 6 at 19:56