Changing text on a file using scripts [duplicate]
This question already has an answer here:
Find and replace text within a file using commands
7 answers
I want to change the PASS_MIN_DAYS = (whatever value is set) to PASS_MIN_DAYS = 15 using a script.The file it's in is /etc/login.defs.
bash scripts text-processing text
marked as duplicate by wjandrea, Sergiy Kolodyazhnyy
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 6 at 23:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Find and replace text within a file using commands
7 answers
I want to change the PASS_MIN_DAYS = (whatever value is set) to PASS_MIN_DAYS = 15 using a script.The file it's in is /etc/login.defs.
bash scripts text-processing text
marked as duplicate by wjandrea, Sergiy Kolodyazhnyy
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 6 at 23:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Find and replace text within a file using commands
7 answers
I want to change the PASS_MIN_DAYS = (whatever value is set) to PASS_MIN_DAYS = 15 using a script.The file it's in is /etc/login.defs.
bash scripts text-processing text
This question already has an answer here:
Find and replace text within a file using commands
7 answers
I want to change the PASS_MIN_DAYS = (whatever value is set) to PASS_MIN_DAYS = 15 using a script.The file it's in is /etc/login.defs.
This question already has an answer here:
Find and replace text within a file using commands
7 answers
bash scripts text-processing text
bash scripts text-processing text
edited Dec 6 at 20:35
dessert
21.9k55997
21.9k55997
asked Dec 6 at 20:00
Ivan Mikhaylov
11
11
marked as duplicate by wjandrea, Sergiy Kolodyazhnyy
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 6 at 23:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by wjandrea, Sergiy Kolodyazhnyy
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 6 at 23:37
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I’d use sed
like this:
sed '/^PASS_MIN_DAYS/s/[0-9]+/15/'
This replaces the number in the line beginning with “PASS_MIN_DAYS” with 15
. To edit the file in place leaving a backup with the .bak
extension, use the following command. By default you need root access to edit the file.
sed -i.bak '/^PASS_MIN_DAYS/s/[0-9]+/15/' /etc/login.defs
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I’d use sed
like this:
sed '/^PASS_MIN_DAYS/s/[0-9]+/15/'
This replaces the number in the line beginning with “PASS_MIN_DAYS” with 15
. To edit the file in place leaving a backup with the .bak
extension, use the following command. By default you need root access to edit the file.
sed -i.bak '/^PASS_MIN_DAYS/s/[0-9]+/15/' /etc/login.defs
add a comment |
I’d use sed
like this:
sed '/^PASS_MIN_DAYS/s/[0-9]+/15/'
This replaces the number in the line beginning with “PASS_MIN_DAYS” with 15
. To edit the file in place leaving a backup with the .bak
extension, use the following command. By default you need root access to edit the file.
sed -i.bak '/^PASS_MIN_DAYS/s/[0-9]+/15/' /etc/login.defs
add a comment |
I’d use sed
like this:
sed '/^PASS_MIN_DAYS/s/[0-9]+/15/'
This replaces the number in the line beginning with “PASS_MIN_DAYS” with 15
. To edit the file in place leaving a backup with the .bak
extension, use the following command. By default you need root access to edit the file.
sed -i.bak '/^PASS_MIN_DAYS/s/[0-9]+/15/' /etc/login.defs
I’d use sed
like this:
sed '/^PASS_MIN_DAYS/s/[0-9]+/15/'
This replaces the number in the line beginning with “PASS_MIN_DAYS” with 15
. To edit the file in place leaving a backup with the .bak
extension, use the following command. By default you need root access to edit the file.
sed -i.bak '/^PASS_MIN_DAYS/s/[0-9]+/15/' /etc/login.defs
edited Dec 6 at 20:31
answered Dec 6 at 20:16
dessert
21.9k55997
21.9k55997
add a comment |
add a comment |