That just gives me the users who have delete. I need the other rights they have that aren't delete.<br><br>Thanks,<br><br>Will<br><br><div class="gmail_quote">On Mon, Oct 29, 2012 at 4:24 PM, Kevin Cozens <span dir="ltr"><<a href="mailto:kevin-4dS5u2o1hCn3fQ9qLvQP4Q@public.gmane.org" target="_blank">kevin@ve3syb.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 12-10-29 01:44 PM, William Weaver wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So I'm still working on my awk skills. I'm trying to write a script that<br>
allows me to pase a csv file of user rights and get all users that have a<br>
specific right. Then using that list of users find all other rights those<br>
users have.<br>
</blockquote>
<br></div>
As a rule I use awk where I need to process individual lines of a file to alter the output somehow or extract info from each line. For what you are suggesting I would probably lean towards using Perl. Depends whether you are trying to learn awk or have restrictions preventing use of Perl.<div class="im">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
UserName,Right<br>
Bob,Add<br>
Ben,Add<br>
Ben,Delete<br>
Tommy,Add<br>
Sarah,Delete<br>
Sarah,Edit<br>
<br>
My result set if I search for users with Delete should look like<br>
<br>
Ben,Delete<br>
Sarah,Edit<br>
</blockquote>
<br></div>
I think you have an error in the example. Are you trying to format the output in to "name,list of perms" (ie. Ben,Add,Delete)?<br>
<br>
You may be better off parsing the input and building associative arrays. One array for each user with their list of permissions. You can then print the output of the arrays with the perms for each user that can be piped to a file for later searching. Alternatively, you can build arrays based on the perms and get a list of names who have a given permission.<br>
<br>
You also need to watch out for CSV fields enclosed in quotes where there might be a comma between the quotes. It will mess up splitting the CSV input in to fields.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
/Delete/ { Users[$1]=$2 }<br>
/Delete/ {print $1, " - ", Users[$1]}<br>
</blockquote>
<br></div>
/Delete/ { Users[$1]=$2; print $1, " - ", Users[$1]; }<br>
or<br>
/Delete/ {<br>
Users[$1]=$2;<br>
print $1, " - ", Users[$1];<br>
}<br>
<br>
You can also do the print statement as:<br>
printf "%s - %s",$1, Users[$1];<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
-- <br>
Cheers!<br>
<br>
Kevin.<br>
<br>
<a href="http://www.ve3syb.ca/" target="_blank">http://www.ve3syb.ca/</a> |"Nerds make the shiny things that distract<br>
Owner of Elecraft K2 #2172 | the mouth-breathers, and that's why we're<br>
| powerful!"<br>
#include <disclaimer/favourite> | --Chris Hardwick</font></span><div class="HOEnZb"><div class="h5"><br>
--<br>
The Toronto Linux Users Group. Meetings: <a href="http://gtalug.org/" target="_blank">http://gtalug.org/</a><br>
TLUG requests: Linux topics, No HTML, wrap text below 80 columns<br>
How to UNSUBSCRIBE: <a href="http://gtalug.org/wiki/Mailing_lists" target="_blank">http://gtalug.org/wiki/<u></u>Mailing_lists</a><br>
</div></div></blockquote></div><br>