Sed - change some thing but not all
I love sed...that being said...
I'm trying to figure out a command that will change one line, but not the comment above the line I'm changing... I know it's something simple. # PASS_MAX_DAYS sets maximum password days PASS_MAX_DAYS 999999 So I use: Code:
sed '/#/!s|PASS_MAX_DAYS|PASS_MAX_DAYS 180|g' /etc/login.defs PASS_MAX_DAYS 180 999999 Am I missing a switch somewhere? I guess I want to replace the line and the spaces are throwing me off. Thanks again! |
Code:
sed 's/^PASS_MAX_DAYS *[0-9]*/PASS_MAX_DAYS 180/' |
Thanks for the reply Radoulov. That command you just sent does the same thing though. It doesn't remove the 99999.
|
Quote:
Code:
echo "# PASS_MAX_DAYS sets maximum password days Code:
zsh 4.3.2% echo "# PASS_MAX_DAYS sets maximum password days |
When I type in your echo command it comes out correct, but when I point what you've done in sed to the file itself it doesn't work and I think it's looking for the 999999 number. I don't think I want to look for the 99999 either because if the system has any other number I still want it replaced. Is there a switch in sed to tell it to overwrite the whole line?
Again thanks for the help! |
Thanks for the help radoulov.... I figured it out with your help.
Code:
sed '/^PASS_MAX_DAYS/ c\PASS_MAX_DAYS 180' /etc/login.defs |
All times are GMT -5. The time now is 11:48 PM. |