Reputation: 794
I have a list of users that have logged in during the past 180 days and a list of total users from LDAP. Each list is within text file and each name is on its own line. With sed or awk can I have a script read from current-users.txt and delete from total-users.txt to give me a text document that has all of the inactive accounts for the past 180 days?
Thanks in advance!
Upvotes: 0
Views: 83
Reputation: 45353
Using awk
awk 'NR==FNR{a[$1];next} !($1 in a)' current_users total_users
Upvotes: 1
Reputation: 290515
No need to sed or awk, grep
suffices:
grep -vf current-users.txt total-users
It returns all the lines that are in total_users
but not in current-users.txt
.
grep -f
gets parameters from a file.grep -v
inverts the result.$ cat total_users
one
two
three
four
$ cat some_users
two
four
$ grep -vf some_users total_users
one
three
Upvotes: 2