Piping output of command to sed
Clash Royale CLAN TAG#URR8PPP
How would i pipe results of a command to sed without using '>>' so it appends that output to file?
What i want is something like this
command | sed -i "$command output" file
io-redirection
|
show 3 more comments
How would i pipe results of a command to sed without using '>>' so it appends that output to file?
What i want is something like this
command | sed -i "$command output" file
io-redirection
2
What are you trying to accomplish ?
– don_crissti
Dec 10 at 21:42
2
command | tee -a file
orcommand >> file
?
– cryptarch
Dec 10 at 21:45
2
yeah, this has been beaten to death...
– don_crissti
Dec 10 at 21:46
3
That's nonsense... There's a thing callednoclobber
if you're paranoid about accidentally overwriting files via redirection...
– don_crissti
Dec 10 at 22:01
1
Your post is a typical example of a XY question. Explain what are you trying to accomplish and why.
– don_crissti
Dec 10 at 22:07
|
show 3 more comments
How would i pipe results of a command to sed without using '>>' so it appends that output to file?
What i want is something like this
command | sed -i "$command output" file
io-redirection
How would i pipe results of a command to sed without using '>>' so it appends that output to file?
What i want is something like this
command | sed -i "$command output" file
io-redirection
io-redirection
edited Dec 10 at 21:57
asked Dec 10 at 21:40
wedran
993
993
2
What are you trying to accomplish ?
– don_crissti
Dec 10 at 21:42
2
command | tee -a file
orcommand >> file
?
– cryptarch
Dec 10 at 21:45
2
yeah, this has been beaten to death...
– don_crissti
Dec 10 at 21:46
3
That's nonsense... There's a thing callednoclobber
if you're paranoid about accidentally overwriting files via redirection...
– don_crissti
Dec 10 at 22:01
1
Your post is a typical example of a XY question. Explain what are you trying to accomplish and why.
– don_crissti
Dec 10 at 22:07
|
show 3 more comments
2
What are you trying to accomplish ?
– don_crissti
Dec 10 at 21:42
2
command | tee -a file
orcommand >> file
?
– cryptarch
Dec 10 at 21:45
2
yeah, this has been beaten to death...
– don_crissti
Dec 10 at 21:46
3
That's nonsense... There's a thing callednoclobber
if you're paranoid about accidentally overwriting files via redirection...
– don_crissti
Dec 10 at 22:01
1
Your post is a typical example of a XY question. Explain what are you trying to accomplish and why.
– don_crissti
Dec 10 at 22:07
2
2
What are you trying to accomplish ?
– don_crissti
Dec 10 at 21:42
What are you trying to accomplish ?
– don_crissti
Dec 10 at 21:42
2
2
command | tee -a file
or command >> file
?– cryptarch
Dec 10 at 21:45
command | tee -a file
or command >> file
?– cryptarch
Dec 10 at 21:45
2
2
yeah, this has been beaten to death...
– don_crissti
Dec 10 at 21:46
yeah, this has been beaten to death...
– don_crissti
Dec 10 at 21:46
3
3
That's nonsense... There's a thing called
noclobber
if you're paranoid about accidentally overwriting files via redirection...– don_crissti
Dec 10 at 22:01
That's nonsense... There's a thing called
noclobber
if you're paranoid about accidentally overwriting files via redirection...– don_crissti
Dec 10 at 22:01
1
1
Your post is a typical example of a XY question. Explain what are you trying to accomplish and why.
– don_crissti
Dec 10 at 22:07
Your post is a typical example of a XY question. Explain what are you trying to accomplish and why.
– don_crissti
Dec 10 at 22:07
|
show 3 more comments
1 Answer
1
active
oldest
votes
command | sed [sed commands] | tee -a FILE
Omitting the '-i
' will use standard input for sed magic, the '-a
' for tee
will append sed's output to FILE instead of overwriting when used without -a
I know this, but using >> is not recommended, as you can accidentally type > instead and overwrite the file.
– wedran
Dec 10 at 21:55
1
That's your reason for not using>>
? If you don't want to type>
accidentally then watch what you type. If you're that worried, back up the file before writing it. Sed won't stop you from shooting yourself in the foot.
– cryptarch
Dec 10 at 22:10
I'm having trouble gettingcommand | sed "$command output" | tee -a FILE
to do anything, because"$command output"
is not defined. The entire thing is predicated on a misunderstanding of sed and shell variables and pipes. The answer could be improved by showing an explicit example demonstrating that sed really can be used in this way, and covers some use case which is not satisfied by simplycommand | tee -a FILE
.
– cryptarch
Dec 10 at 22:25
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%2f487219%2fpiping-output-of-command-to-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
command | sed [sed commands] | tee -a FILE
Omitting the '-i
' will use standard input for sed magic, the '-a
' for tee
will append sed's output to FILE instead of overwriting when used without -a
I know this, but using >> is not recommended, as you can accidentally type > instead and overwrite the file.
– wedran
Dec 10 at 21:55
1
That's your reason for not using>>
? If you don't want to type>
accidentally then watch what you type. If you're that worried, back up the file before writing it. Sed won't stop you from shooting yourself in the foot.
– cryptarch
Dec 10 at 22:10
I'm having trouble gettingcommand | sed "$command output" | tee -a FILE
to do anything, because"$command output"
is not defined. The entire thing is predicated on a misunderstanding of sed and shell variables and pipes. The answer could be improved by showing an explicit example demonstrating that sed really can be used in this way, and covers some use case which is not satisfied by simplycommand | tee -a FILE
.
– cryptarch
Dec 10 at 22:25
add a comment |
command | sed [sed commands] | tee -a FILE
Omitting the '-i
' will use standard input for sed magic, the '-a
' for tee
will append sed's output to FILE instead of overwriting when used without -a
I know this, but using >> is not recommended, as you can accidentally type > instead and overwrite the file.
– wedran
Dec 10 at 21:55
1
That's your reason for not using>>
? If you don't want to type>
accidentally then watch what you type. If you're that worried, back up the file before writing it. Sed won't stop you from shooting yourself in the foot.
– cryptarch
Dec 10 at 22:10
I'm having trouble gettingcommand | sed "$command output" | tee -a FILE
to do anything, because"$command output"
is not defined. The entire thing is predicated on a misunderstanding of sed and shell variables and pipes. The answer could be improved by showing an explicit example demonstrating that sed really can be used in this way, and covers some use case which is not satisfied by simplycommand | tee -a FILE
.
– cryptarch
Dec 10 at 22:25
add a comment |
command | sed [sed commands] | tee -a FILE
Omitting the '-i
' will use standard input for sed magic, the '-a
' for tee
will append sed's output to FILE instead of overwriting when used without -a
command | sed [sed commands] | tee -a FILE
Omitting the '-i
' will use standard input for sed magic, the '-a
' for tee
will append sed's output to FILE instead of overwriting when used without -a
edited Dec 10 at 22:48
answered Dec 10 at 21:47
Jaleks
1,338422
1,338422
I know this, but using >> is not recommended, as you can accidentally type > instead and overwrite the file.
– wedran
Dec 10 at 21:55
1
That's your reason for not using>>
? If you don't want to type>
accidentally then watch what you type. If you're that worried, back up the file before writing it. Sed won't stop you from shooting yourself in the foot.
– cryptarch
Dec 10 at 22:10
I'm having trouble gettingcommand | sed "$command output" | tee -a FILE
to do anything, because"$command output"
is not defined. The entire thing is predicated on a misunderstanding of sed and shell variables and pipes. The answer could be improved by showing an explicit example demonstrating that sed really can be used in this way, and covers some use case which is not satisfied by simplycommand | tee -a FILE
.
– cryptarch
Dec 10 at 22:25
add a comment |
I know this, but using >> is not recommended, as you can accidentally type > instead and overwrite the file.
– wedran
Dec 10 at 21:55
1
That's your reason for not using>>
? If you don't want to type>
accidentally then watch what you type. If you're that worried, back up the file before writing it. Sed won't stop you from shooting yourself in the foot.
– cryptarch
Dec 10 at 22:10
I'm having trouble gettingcommand | sed "$command output" | tee -a FILE
to do anything, because"$command output"
is not defined. The entire thing is predicated on a misunderstanding of sed and shell variables and pipes. The answer could be improved by showing an explicit example demonstrating that sed really can be used in this way, and covers some use case which is not satisfied by simplycommand | tee -a FILE
.
– cryptarch
Dec 10 at 22:25
I know this, but using >> is not recommended, as you can accidentally type > instead and overwrite the file.
– wedran
Dec 10 at 21:55
I know this, but using >> is not recommended, as you can accidentally type > instead and overwrite the file.
– wedran
Dec 10 at 21:55
1
1
That's your reason for not using
>>
? If you don't want to type >
accidentally then watch what you type. If you're that worried, back up the file before writing it. Sed won't stop you from shooting yourself in the foot.– cryptarch
Dec 10 at 22:10
That's your reason for not using
>>
? If you don't want to type >
accidentally then watch what you type. If you're that worried, back up the file before writing it. Sed won't stop you from shooting yourself in the foot.– cryptarch
Dec 10 at 22:10
I'm having trouble getting
command | sed "$command output" | tee -a FILE
to do anything, because "$command output"
is not defined. The entire thing is predicated on a misunderstanding of sed and shell variables and pipes. The answer could be improved by showing an explicit example demonstrating that sed really can be used in this way, and covers some use case which is not satisfied by simply command | tee -a FILE
.– cryptarch
Dec 10 at 22:25
I'm having trouble getting
command | sed "$command output" | tee -a FILE
to do anything, because "$command output"
is not defined. The entire thing is predicated on a misunderstanding of sed and shell variables and pipes. The answer could be improved by showing an explicit example demonstrating that sed really can be used in this way, and covers some use case which is not satisfied by simply command | tee -a FILE
.– cryptarch
Dec 10 at 22:25
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f487219%2fpiping-output-of-command-to-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
2
What are you trying to accomplish ?
– don_crissti
Dec 10 at 21:42
2
command | tee -a file
orcommand >> file
?– cryptarch
Dec 10 at 21:45
2
yeah, this has been beaten to death...
– don_crissti
Dec 10 at 21:46
3
That's nonsense... There's a thing called
noclobber
if you're paranoid about accidentally overwriting files via redirection...– don_crissti
Dec 10 at 22:01
1
Your post is a typical example of a XY question. Explain what are you trying to accomplish and why.
– don_crissti
Dec 10 at 22:07