How to combine two text formatting commands into one? The Next CEO of Stack Overflowcombine text files column-wiseRun two commands on one argument (without scripting)combine two text files with adding some separator between?How can I append and prepend text to single line text output and save it all to one file?Combine two greps into a single commandCombine SED commandsI'd like to use one of three commands sed (number ranges)How to insert text alternatively from two files with a common patternCombine two file into one fileCombine files into one
Does the Brexit deal have to be agreed by both Houses?
How do I construct this japanese bowl?
How do we know the LHC results are robust?
How to use tikz in fbox?
Is it my responsibility to learn a new technology in my own time my employer wants to implement?
What is the purpose of the Evocation wizard's Potent Cantrip feature?
How long to clear the 'suck zone' of a turbofan after start is initiated?
Why does standard notation not preserve intervals (visually)
Is HostGator storing my password in plaintext?
Removing read access from a file
Why Were Madagascar and New Zealand Discovered So Late?
forest, changing `s sep` such that it is at each second end node larger?
Is it okay to store user locations?
What is meant by a M next to a roman numeral?
Increase performance creating Mandelbrot set in python
How to count occurrences of text in a file?
Can a caster that cast Polymorph on themselves stop concentrating at any point even if their Int is low?
Is it a good idea to use COLUMN AS (left([Another_Column],(4)) instead of LEFT in the select?
Can a single photon have an energy density?
What is the difference between "behavior" and "behaviour"?
I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin
Opposite of a diet
Why did we only see the N-1 starfighters in one film?
When airplanes disconnect from a tanker during air to air refueling, why do they bank so sharply to the right?
How to combine two text formatting commands into one?
The Next CEO of Stack Overflowcombine text files column-wiseRun two commands on one argument (without scripting)combine two text files with adding some separator between?How can I append and prepend text to single line text output and save it all to one file?Combine two greps into a single commandCombine SED commandsI'd like to use one of three commands sed (number ranges)How to insert text alternatively from two files with a common patternCombine two file into one fileCombine files into one
How does one combine two commands like the ones shown below into one command with one output file?
first command:
printf '%sn' 001..500 input > output
second command:
sed 's/^/PREFIX /; s/$/ SUFFIX/' input > output
text-processing sed command-line command text-formatting
add a comment |
How does one combine two commands like the ones shown below into one command with one output file?
first command:
printf '%sn' 001..500 input > output
second command:
sed 's/^/PREFIX /; s/$/ SUFFIX/' input > output
text-processing sed command-line command text-formatting
add a comment |
How does one combine two commands like the ones shown below into one command with one output file?
first command:
printf '%sn' 001..500 input > output
second command:
sed 's/^/PREFIX /; s/$/ SUFFIX/' input > output
text-processing sed command-line command text-formatting
How does one combine two commands like the ones shown below into one command with one output file?
first command:
printf '%sn' 001..500 input > output
second command:
sed 's/^/PREFIX /; s/$/ SUFFIX/' input > output
text-processing sed command-line command text-formatting
text-processing sed command-line command text-formatting
asked yesterday
Anonymous UserAnonymous User
336
336
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I realise you've answered your question, but a simpler solution would be to put the prefix and suffix in the printf
command.
printf 'PREFIX %s SUFFIXn' 001..500 > output
(I'm not sure if the input
part should be there. It's absent in your answer.)
Oh even better! Awesome, thanks! p.s. You just taught me something... :)
– Anonymous User
yesterday
How come the sed command changed to look more simple? How is that possible? Is that like printf's equivalent?
– Anonymous User
yesterday
Thesed
command replaces the beginning^
and end$
of each line.printf
defines how it will "print" the numbers, i.e. each line consist ofPREFIX
followed by a string%s
, then ` SUFFIX` and a newlinen
. The numbers expanded from001..500
replace the string placeholder%s
.
– Sparhawk
yesterday
because it doesn't actually need the input, it works fine without.
– Anonymous User
yesterday
Regardinginput
, if this is present, the command will create another line after the numbers, but with the literal stringinput
instead. (I'm presuming you don't want this.)
– Sparhawk
yesterday
|
show 6 more comments
I figured it out!
Both commands as one:
printf '%sn' 001..500 | sed 's/^/PREFIX /; s/$/ SUFFIX/' > output
1
Simpler:printf 'PREFIX %s SUFFIXn' 001..500 >output
– John1024
yesterday
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%2f508877%2fhow-to-combine-two-text-formatting-commands-into-one%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I realise you've answered your question, but a simpler solution would be to put the prefix and suffix in the printf
command.
printf 'PREFIX %s SUFFIXn' 001..500 > output
(I'm not sure if the input
part should be there. It's absent in your answer.)
Oh even better! Awesome, thanks! p.s. You just taught me something... :)
– Anonymous User
yesterday
How come the sed command changed to look more simple? How is that possible? Is that like printf's equivalent?
– Anonymous User
yesterday
Thesed
command replaces the beginning^
and end$
of each line.printf
defines how it will "print" the numbers, i.e. each line consist ofPREFIX
followed by a string%s
, then ` SUFFIX` and a newlinen
. The numbers expanded from001..500
replace the string placeholder%s
.
– Sparhawk
yesterday
because it doesn't actually need the input, it works fine without.
– Anonymous User
yesterday
Regardinginput
, if this is present, the command will create another line after the numbers, but with the literal stringinput
instead. (I'm presuming you don't want this.)
– Sparhawk
yesterday
|
show 6 more comments
I realise you've answered your question, but a simpler solution would be to put the prefix and suffix in the printf
command.
printf 'PREFIX %s SUFFIXn' 001..500 > output
(I'm not sure if the input
part should be there. It's absent in your answer.)
Oh even better! Awesome, thanks! p.s. You just taught me something... :)
– Anonymous User
yesterday
How come the sed command changed to look more simple? How is that possible? Is that like printf's equivalent?
– Anonymous User
yesterday
Thesed
command replaces the beginning^
and end$
of each line.printf
defines how it will "print" the numbers, i.e. each line consist ofPREFIX
followed by a string%s
, then ` SUFFIX` and a newlinen
. The numbers expanded from001..500
replace the string placeholder%s
.
– Sparhawk
yesterday
because it doesn't actually need the input, it works fine without.
– Anonymous User
yesterday
Regardinginput
, if this is present, the command will create another line after the numbers, but with the literal stringinput
instead. (I'm presuming you don't want this.)
– Sparhawk
yesterday
|
show 6 more comments
I realise you've answered your question, but a simpler solution would be to put the prefix and suffix in the printf
command.
printf 'PREFIX %s SUFFIXn' 001..500 > output
(I'm not sure if the input
part should be there. It's absent in your answer.)
I realise you've answered your question, but a simpler solution would be to put the prefix and suffix in the printf
command.
printf 'PREFIX %s SUFFIXn' 001..500 > output
(I'm not sure if the input
part should be there. It's absent in your answer.)
edited yesterday
answered yesterday
SparhawkSparhawk
10.3k744101
10.3k744101
Oh even better! Awesome, thanks! p.s. You just taught me something... :)
– Anonymous User
yesterday
How come the sed command changed to look more simple? How is that possible? Is that like printf's equivalent?
– Anonymous User
yesterday
Thesed
command replaces the beginning^
and end$
of each line.printf
defines how it will "print" the numbers, i.e. each line consist ofPREFIX
followed by a string%s
, then ` SUFFIX` and a newlinen
. The numbers expanded from001..500
replace the string placeholder%s
.
– Sparhawk
yesterday
because it doesn't actually need the input, it works fine without.
– Anonymous User
yesterday
Regardinginput
, if this is present, the command will create another line after the numbers, but with the literal stringinput
instead. (I'm presuming you don't want this.)
– Sparhawk
yesterday
|
show 6 more comments
Oh even better! Awesome, thanks! p.s. You just taught me something... :)
– Anonymous User
yesterday
How come the sed command changed to look more simple? How is that possible? Is that like printf's equivalent?
– Anonymous User
yesterday
Thesed
command replaces the beginning^
and end$
of each line.printf
defines how it will "print" the numbers, i.e. each line consist ofPREFIX
followed by a string%s
, then ` SUFFIX` and a newlinen
. The numbers expanded from001..500
replace the string placeholder%s
.
– Sparhawk
yesterday
because it doesn't actually need the input, it works fine without.
– Anonymous User
yesterday
Regardinginput
, if this is present, the command will create another line after the numbers, but with the literal stringinput
instead. (I'm presuming you don't want this.)
– Sparhawk
yesterday
Oh even better! Awesome, thanks! p.s. You just taught me something... :)
– Anonymous User
yesterday
Oh even better! Awesome, thanks! p.s. You just taught me something... :)
– Anonymous User
yesterday
How come the sed command changed to look more simple? How is that possible? Is that like printf's equivalent?
– Anonymous User
yesterday
How come the sed command changed to look more simple? How is that possible? Is that like printf's equivalent?
– Anonymous User
yesterday
The
sed
command replaces the beginning ^
and end $
of each line. printf
defines how it will "print" the numbers, i.e. each line consist of PREFIX
followed by a string %s
, then ` SUFFIX` and a newline n
. The numbers expanded from 001..500
replace the string placeholder %s
.– Sparhawk
yesterday
The
sed
command replaces the beginning ^
and end $
of each line. printf
defines how it will "print" the numbers, i.e. each line consist of PREFIX
followed by a string %s
, then ` SUFFIX` and a newline n
. The numbers expanded from 001..500
replace the string placeholder %s
.– Sparhawk
yesterday
because it doesn't actually need the input, it works fine without.
– Anonymous User
yesterday
because it doesn't actually need the input, it works fine without.
– Anonymous User
yesterday
Regarding
input
, if this is present, the command will create another line after the numbers, but with the literal string input
instead. (I'm presuming you don't want this.)– Sparhawk
yesterday
Regarding
input
, if this is present, the command will create another line after the numbers, but with the literal string input
instead. (I'm presuming you don't want this.)– Sparhawk
yesterday
|
show 6 more comments
I figured it out!
Both commands as one:
printf '%sn' 001..500 | sed 's/^/PREFIX /; s/$/ SUFFIX/' > output
1
Simpler:printf 'PREFIX %s SUFFIXn' 001..500 >output
– John1024
yesterday
add a comment |
I figured it out!
Both commands as one:
printf '%sn' 001..500 | sed 's/^/PREFIX /; s/$/ SUFFIX/' > output
1
Simpler:printf 'PREFIX %s SUFFIXn' 001..500 >output
– John1024
yesterday
add a comment |
I figured it out!
Both commands as one:
printf '%sn' 001..500 | sed 's/^/PREFIX /; s/$/ SUFFIX/' > output
I figured it out!
Both commands as one:
printf '%sn' 001..500 | sed 's/^/PREFIX /; s/$/ SUFFIX/' > output
edited yesterday
answered yesterday
Anonymous UserAnonymous User
336
336
1
Simpler:printf 'PREFIX %s SUFFIXn' 001..500 >output
– John1024
yesterday
add a comment |
1
Simpler:printf 'PREFIX %s SUFFIXn' 001..500 >output
– John1024
yesterday
1
1
Simpler:
printf 'PREFIX %s SUFFIXn' 001..500 >output
– John1024
yesterday
Simpler:
printf 'PREFIX %s SUFFIXn' 001..500 >output
– John1024
yesterday
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%2f508877%2fhow-to-combine-two-text-formatting-commands-into-one%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