Hello.
I am writing a script that queries the permissions on certain files and displays them in a neat form.
When I run this command string:
Code:
ls -la /etc/hosts | awk '{print $1 " " $2 " " $3 " " $4}'
I get this (which is all that I want displayed in the results from the script):
Code:
-rw------ 1 root root
(btw, I added the " " to the awk argument for a nicer display)
Now, I have several files I want to do this to, so why repeat the awk argument over and over. So, I thought about putting it into a variable:
Code:
PERMS=awk '{print $1 " " $2 " " $3 " " $4}'
ls -la /etc/hosts | $PERMS
but the script never returns anything. I have tried various things, such as adding echo to the variable, but to no avail. Does anyone know of the magic 'thing' that I need to do to get this work?
Thanks...and, sorry, but my awk knowledge is not that great.