I have two files - one with usernames and another with some properties of that user.
Users file looks like
user1
user2
user3
...
....second file Passwdstat
LK
NP
NP
PS
LK
....both files have one to one mapping for user and passwd status.
I want to retreive value for each user , in a very efficient way. which is better than
passwd -S user1 | grep " LK " or something in linux
By one to one mapping, I am assuming when you read line one of the users file, retrieve line 1 of the Passwdstat file, line 2, retrieve line 2, etc. There are a number of ways to do this, I choose to use sed to retrieve the line number from the Passwdstat file: #!/bin/bash cnt=0 while read line do ((cnt+=1)) echo "$line" val2=$(sed -n ''"${cnt}"'p' Passwdstat) echo "$val2" done < users
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |