Hi all ,
i need an help here.!!!! i have a file that contains /etc/passwd files from some servers.
i need a script which search for presence of a user in the servers.
like if i give 51144 to the script. the should be o/p
Please help on this.....
Hi all ,
i need an help here.!!!! i have a file that contains /etc/passwd files from some servers.
i need a script which search for presence of a user in the servers.
like if i give 51144 to the script. the should be o/p
Please help on this.....
awk -v FS=":" -v USER="51144" '
BEGIN { print "user:" USER; }
{
if(NF < 2) TITLE=$1
else if($1 == USER) print TITLE;
}' < data
Or try..
awk '/51144/{print $1}' RS= inputfile
thanks for ur reply Corona688 and michaelrozar17, but i really didnt get what i expected .
ok may be, i will explain little further . i have file thats look like below
like that there are nearly 100 servers , i just want to print the user and the servers where account exists.
Something like this..?
awk -v usr="root" 'BEGIN{print "User:" usr} $0 ~ usr {print $1}' RS= inputfile