I need to do a backup of all users that have been deleted so I have 1 file for the backup and another file for the list of users to backup. I want it use awk to retrieve the details and would like to do it inside awk without while condition.
NOTE: We are working on a linux environment.
1st file
dn: uid=testuser1,ou=people,ou=identities
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
dn: uid=testuser1,ou=people,ou=identities
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
2nd file
dn: uid=testuser1,ou=people,ou=identities
I have used below but it’s too slow
while read line
do
delcommand=” awk ‘/”$line”/,/pattern|^$/’ backup.ldif >> backupfiledeleted.txt
eval “$delcommand”
done < listtodelete.txt
Expected to print the set of details for the user:
dn: uid=testuser1,ou=people,ou=identities
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
Cj Calaguian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.