Sponsored Content
Top Forums Shell Programming and Scripting sed - matching pattern one but not pattern two Post 302314202 by RobertBerrie on Thursday 7th of May 2009 04:07:46 PM
Old 05-07-2009
sed - matching pattern one but not pattern two

All,

I have the following file:
--------------------------------------
#
# /etc/pam.d/common-password - password-related modules common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of modules that define the services to be
# used to change user passwords. The default is pam_unix2 in combination
# with pam_pwcheck.
# The "nullok" option allows users to change an empty password, else
# empty passwords are treated as locked accounts.
#
# To enable Blowfish or MD5 passwords, you should edit
# /etc/default/passwd.
#
# Alternate strength checking for passwords should be configured
# in /etc/security/pam_pwcheck.conf.
#
# pam_make can be used to rebuild NIS maps after password change.
#
password required pam_passwdqc.so retry=5 ask_oldauthok min=disabled,8,8,8,8 passphrase=0 random=0 force=everyone
password required pam_pwcheck.so nullok
password required pam_unix2.so nullok use_authtok
#password required pam_make.so /var/yp
--------------------------------------------------------------------

What I would like to do is generate a sed command that will:
Add "use_first_pass" to a line if the line contains "pam_unix2.so" but the line does *not* contain "use_first_pass".
The remainer of the file should be left alone.

I can generate the logic with:
a regex of:
(.*pam_unix2\.so.*) (?!.*use_first_pass.*)

I am having trouble translating that into a sed expression.

Thanks,
-Robert
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pattern matching sed

MSG="THERE WERE XX RECORDS IN ERROR TABLE,AAAA, WHEN LOADING THE BBBB TABLE WITH EXTRACT FROM CCCC INTO TABLES FOR , DATABASE DDDD." echo "$MSG" > /tmp/mplanmsg.$$.out I wan to replace XX with the content in $recordXX cat /tmp/mplanmsg.$$.out|sed 's/XX/\$recordXX/g'| sed... (3 Replies)
Discussion started by: leemjesse
3 Replies

2. Shell Programming and Scripting

sed pattern matching

Hi, I have a file which contains a word like ravi and ravi30. i want to replace only the word ravi with xxx for that i am using the below sed command sed -e 's/ravi/xxx/g' . but the above command out put is xxx and xxx30 but i dont need to change ravi30 please guide me how to proceed.... (4 Replies)
Discussion started by: ravi_rn
4 Replies

3. Shell Programming and Scripting

sed pattern matching

Hi all, if I have the following piece (repeating) of text within a file and I wish to delete it via sed a b c d e <tr> <td><img alt="" height="1" width="3" src="/testweb/view/browser/images/shim.gif"></td><td><img alt="" height="1" ... (4 Replies)
Discussion started by: srage
4 Replies

4. Shell Programming and Scripting

sed pattern matching

Unfortunately this chap has been banned for some reason and I was looking forward to the resolution of his question: - https://www.unix.com/shell-programming-scripting/123118-append-position-28-33-a.html He was asking if you can use sed to match a pattern you want to replace within a... (6 Replies)
Discussion started by: steadyonabix
6 Replies

5. Shell Programming and Scripting

SED pattern matching help

Hello All, I have the following lines in a file <address location="test" ConnectionName="test" /> I want to replace the above lines by <address location="test123" /> I am usind SED and not able to remove the new line characters between the two lines. Can anyone please help... (4 Replies)
Discussion started by: ramk
4 Replies

6. Shell Programming and Scripting

help! Pattern Matching in vi or sed

I have a bunch of conf files, that contain the fully qualified names of servers. I would like to be able to use some sort of pattern matching with sed or vi, or whatever, to pull out the fully qualified server names, and dump them in a file. It just needs to work across several unix os. So, I... (4 Replies)
Discussion started by: tabini
4 Replies

7. Shell Programming and Scripting

Help with sed pattern matching

Hi My log file is Testtmp2 cat Testtmp2 12:12:38 12:14:29 12:17:34 12:19:08 12:20:10 12:21:35 12:22:20 12:22:26 12:22:34 12:22:38 12:28:14 12:31:35 12:32:50 12:33:04 (3 Replies)
Discussion started by: rahkumar
3 Replies

8. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

9. Shell Programming and Scripting

Use sed to get first matching pattern

HI, I have a file: listenerport: - 1521 - 10520 - 10521 - 10522 - 10523 instances: listenerport: listenerport: - 1521 - 10540 - 10541 - 10542 - 10543 instances: ... (5 Replies)
Discussion started by: netbanker
5 Replies

10. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies
pam_sm_chauthtok(3)					     Library Functions Manual					       pam_sm_chauthtok(3)

NAME
pam_sm_chauthtok - Service provider implementation for pam_chauthtok SYNOPSIS
[ flag ... ] file ... [ library ... ] DESCRIPTION
In response to a call to the PAM framework calls from the modules listed in the pam.conf(4) file. The password management provider sup- plies the back-end functionality for this interface function. changes the authentication token associated with a particular user referenced by the authentication handle, pamh. The following flag may be passed in to The password service should not generate any messages. The password service should only update those passwords that have aged. If this flag is not passed, the password service should update all passwords. The password service should only perform preliminary checks. No passwords should be updated. The password service should update passwords. Note that and can not be set at the same time. Upon successful completion of the call, the authentication token of the user will be ready for change or will be changed (depending upon the flag) in accordance with the authentication scheme configured within the system. The argc argument represents the number of module options passed in from the configuration file pam.conf(4). argv specifies the module options, which are interpreted and processed by the password management service. Please refer to the specific module man pages for the various available options. It is the responsibility of to determine if the new password meets certain strength requirements. may continue to re-prompt the user (for a limited number of times) for a new password until the password entered meets the strength requirements. Before returning, should call and retrieve both and If both are NULL, should set them to the new and old passwords as entered by the user. APPLICATION USAGE
Refer to pam(3) for information on thread-safety of PAM interfaces. NOTES
The PAM framework invokes the password services twice. The first time the modules are invoked with the flag, During this stage, the pass- word modules should only perform preliminary checks (ping remote name services to see if they are ready for updates, for example). If a password module detects a transient error (remote name service temporarily down, for example) it should return to the PAM framework, which will immediately return the error back to the application. If all password modules pass the preliminary check, the PAM framework invokes the password services again with the flag, During this stage, each password module should proceed to update the appropriate password. Any error will again be reported back to application. If a service module receives the flag, it should check whether the password has aged or expired. If the password has aged or expired, then the service module should proceed to update the password. If the status indicates that the password has not yet aged/expired, then the password module should return If a user's password has aged or expired, a PAM account module could save this information as state in the authentication handle, pamh, using The related password management module could retrieve this information using to determine whether or not it should prompt the user to update the password for this particular module. RETURN VALUES
Upon successful completion, must be returned. The following values may also be returned: No permission. Authentication token manipulation error. Old authentication token cannot be recovered. Authentication token lock busy. Authentication token aging disabled. User unknown to password service. Preliminary check by password service failed. SEE ALSO
pam(3), pam_chauthtok(3), pam.conf(4). pam_sm_chauthtok(3)
All times are GMT -4. The time now is 07:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy