How can I copy the records of the file âÂÂ/etc/bashrcâ that have the âÂÂTMOUTâ string except those containing the âÂÂread-onlyâ string, to the file?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
my question is about centos file copy
How can I copy the records of the file âÂÂ/etc/bashrcâ that have the âÂÂTMOUTâ string except those containing the âÂÂread-onlyâ string, to the file?
text-processing
add a comment |Â
up vote
0
down vote
favorite
my question is about centos file copy
How can I copy the records of the file âÂÂ/etc/bashrcâ that have the âÂÂTMOUTâ string except those containing the âÂÂread-onlyâ string, to the file?
text-processing
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
my question is about centos file copy
How can I copy the records of the file âÂÂ/etc/bashrcâ that have the âÂÂTMOUTâ string except those containing the âÂÂread-onlyâ string, to the file?
text-processing
my question is about centos file copy
How can I copy the records of the file âÂÂ/etc/bashrcâ that have the âÂÂTMOUTâ string except those containing the âÂÂread-onlyâ string, to the file?
text-processing
text-processing
edited Sep 25 '17 at 16:16
Kusalananda
106k14209327
106k14209327
asked Sep 25 '17 at 16:00
JaxTeller
62
62
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
grep 'TMOUT' /etc/bashrc | grep -v 'read-only' >output
This first extracts all lines from /etc/bashrc
that contains the string TMOUT
. The second grep
removes all of those lines that also contain the string read-only
. The output is saved to the file output
.
add a comment |Â
up vote
0
down vote
With just one command:
awk '/TMOUT/ && !/read-only/' < /etc/bashrc > output
Or:
sed '/TMOUT/!d; /read-only/d' < /etc/bashrc > output
(d
elete the lines that don't (!
) contain TMOUT
and those that contain read-only
).
Those also have the advantage of not clobbering the output
file if /etc/bashrc
can't be opened.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
grep 'TMOUT' /etc/bashrc | grep -v 'read-only' >output
This first extracts all lines from /etc/bashrc
that contains the string TMOUT
. The second grep
removes all of those lines that also contain the string read-only
. The output is saved to the file output
.
add a comment |Â
up vote
1
down vote
accepted
grep 'TMOUT' /etc/bashrc | grep -v 'read-only' >output
This first extracts all lines from /etc/bashrc
that contains the string TMOUT
. The second grep
removes all of those lines that also contain the string read-only
. The output is saved to the file output
.
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
grep 'TMOUT' /etc/bashrc | grep -v 'read-only' >output
This first extracts all lines from /etc/bashrc
that contains the string TMOUT
. The second grep
removes all of those lines that also contain the string read-only
. The output is saved to the file output
.
grep 'TMOUT' /etc/bashrc | grep -v 'read-only' >output
This first extracts all lines from /etc/bashrc
that contains the string TMOUT
. The second grep
removes all of those lines that also contain the string read-only
. The output is saved to the file output
.
edited Sep 25 '17 at 16:24
answered Sep 25 '17 at 16:15
Kusalananda
106k14209327
106k14209327
add a comment |Â
add a comment |Â
up vote
0
down vote
With just one command:
awk '/TMOUT/ && !/read-only/' < /etc/bashrc > output
Or:
sed '/TMOUT/!d; /read-only/d' < /etc/bashrc > output
(d
elete the lines that don't (!
) contain TMOUT
and those that contain read-only
).
Those also have the advantage of not clobbering the output
file if /etc/bashrc
can't be opened.
add a comment |Â
up vote
0
down vote
With just one command:
awk '/TMOUT/ && !/read-only/' < /etc/bashrc > output
Or:
sed '/TMOUT/!d; /read-only/d' < /etc/bashrc > output
(d
elete the lines that don't (!
) contain TMOUT
and those that contain read-only
).
Those also have the advantage of not clobbering the output
file if /etc/bashrc
can't be opened.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
With just one command:
awk '/TMOUT/ && !/read-only/' < /etc/bashrc > output
Or:
sed '/TMOUT/!d; /read-only/d' < /etc/bashrc > output
(d
elete the lines that don't (!
) contain TMOUT
and those that contain read-only
).
Those also have the advantage of not clobbering the output
file if /etc/bashrc
can't be opened.
With just one command:
awk '/TMOUT/ && !/read-only/' < /etc/bashrc > output
Or:
sed '/TMOUT/!d; /read-only/d' < /etc/bashrc > output
(d
elete the lines that don't (!
) contain TMOUT
and those that contain read-only
).
Those also have the advantage of not clobbering the output
file if /etc/bashrc
can't be opened.
answered Sep 25 '17 at 16:28
Stéphane Chazelas
284k53523860
284k53523860
add a comment |Â
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%2f394343%2fhow-can-i-copy-the-records-of-the-file-etc-bashrc-that-have-the-tmout-strin%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