0

My teacher provided us with a file called myProcesses that has the processes from many people, my objective is to cut out all processes for a user as defined by a variable, how can i achieve this?

Here are my variables so far. command=grep user=mhalprin file=myProcesses

With this, i am able to cut all processes that include "mhalprin" somewhere in the myProcesses file, but one of those include the "root" user because it has "mhalprin" at the end, how can i cut that out of this command? Screen shot of output

Mitch
  • 21
  • 1
  • 1
  • 7
  • Don't use `grep` use `awk` and match on a specific field? – Etan Reisner Oct 14 '15 at 17:13
  • Good idea, but im unfamiliar with Awk, ill have to do some searching on how i can user this to my advantage, thanks! – Mitch Oct 14 '15 at 17:24
  • found the awk command. `awk '$3 == "mhalprin"' myProcesses But now i cant figure out a way to use my variable in this command.. – Mitch Oct 14 '15 at 17:47
  • [How to use shell variables in awk script](http://stackoverflow.com/q/19075671/258523) – Etan Reisner Oct 14 '15 at 18:16
  • Better [edit] your question showing some sample input, desired output and what you tried. No screenshots. Currently it is quite confusing. – fedorqui Oct 20 '15 at 10:34

0 Answers0