nesiuna_1
asked on
how to parse a large file for information
I need to get information from a master file that contains user names and machines.
The 4th field contains the usernames and the 9th field contains systems that the user has access to.
My task is to create a list in 2 columns ( user host) that will list a user and every machines he/she has access to. The username will be repeated for each machine in the file.
i am looking for a simple script that can accomplish this.Can any scripting guru please help?
Thanks in advance.
The 4th field contains the usernames and the 9th field contains systems that the user has access to.
My task is to create a list in 2 columns ( user host) that will list a user and every machines he/she has access to. The username will be repeated for each machine in the file.
i am looking for a simple script that can accomplish this.Can any scripting guru please help?
Thanks in advance.
Please give some sample input/output.
ASKER
this is the input file:
+gshepher:Yi/mOb6QeRcaU:50 32:Greg Shepherd:/home/gshepher:/u sr/bin/tcs h::staff,d evelop:ap1 -bb15,ap1- bb15ua
t,ap1-chase,ap1-chasebb,ap 1-cvmssm,a p1-gpcorr, ap1-gpmor, ap1-gprc
i need to parse the 4th field and the 9th field.
The 4th field is the username and the 9th field is the hostnames
what i need is a printout in this format:
User Hostname
user1 host1
user1 host2
user2 host1
user2 host2
+gshepher:Yi/mOb6QeRcaU:50
t,ap1-chase,ap1-chasebb,ap
i need to parse the 4th field and the 9th field.
The 4th field is the username and the 9th field is the hostnames
what i need is a printout in this format:
User Hostname
user1 host1
user1 host2
user2 host1
user2 host2
awk -F, '{printf "%-10s\t%s\n",$4,$9}' inputfile
awk -F: 'BEGIN{printf "%s\t%s\n","User","Hostnam e"}{printf "%s\t%s\n",$4,$9}' inputfile
(-F: because colon is the field separator)
(-F: because colon is the field separator)
ASKER
The output of this script is this:
Felix Roytfeld ap8-qa,perfap1-dv,perfdb1- dv,perfwb1 -dv,sjcapp 05
But what i am looking for something like this:
User Host
Felix Roytfeld ap8-qa
Felix Roytfeld perfap1-dv
Felix Roytfeld perfb1-dv
Felix Roytfeld sjcapp05
How can i the program to print out in this format?
Thanks
Felix Roytfeld ap8-qa,perfap1-dv,perfdb1-
But what i am looking for something like this:
User Host
Felix Roytfeld ap8-qa
Felix Roytfeld perfap1-dv
Felix Roytfeld perfb1-dv
Felix Roytfeld sjcapp05
How can i the program to print out in this format?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much for your professional help.
i really appreciate the timely response.
i really appreciate the timely response.
awk '{print $1, $9}' filename
if you can provide sample file data then script can be improved