Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk one liner need HELP with quotes.

Status
Not open for further replies.

shellnewbie

Technical User
Dec 9, 2010
4
FR
Dear all,

As i am trying to set-up quotas on users'home.

I would like to have all uid and gid the same for those user's directories. Then find out all the sub files and folder who's GID is different from UID, and send them to a file.

Here is a sample of my working directory :

drwxrwx--- 14 4100 4100 4096 Apr 30 2008 user1
drwxr-x--- 30 50037 20184 4096 Apr 30 2008 user2
drwxrwx--- 6 50161 50161 4096 May 01 2008 superad2
drwxrwx--- 35 50236 50236 4096 May 01 2008 superad3


SERVER$ls -ld * | awk '{if ($3==$4) print $0}'
this line removed folder who have a wrong gid on the folder home's user. ==>

such as this line :
drwxr-x--- 30 50037 20184 4096 Apr 30 2008 user2

then when i only have uid with same gid folders, im trying to make a find command which i will reuse in a bash shell to execute all those find and redirect the result in a file.

SERVER$ls -ld * | awk '{if ($3==$4) print "find",$NF " -ls | awk" "{if ($3 != $4) print $0 }"}'

find user1 -ls | awk{if ($3 != $4) print $0 }
find user2 -ls | awk{if ($3 != $4) print $0 }

The problem is that im missing the quotes for my if.

There undoubtly on awk-line command able to do what im searching for. but as i am still learning bash, and because my programming skills are quite weak, i beg your help.

eager to understand better.
Thanks
French_dude.
 
Hello,
I searched a bit, and i found that i am able to add simple quote with a print in awk using this

'"'"'" '"'"'"
but as i am already using simple quotes once, this will not works.

By the way there was a mistake in my print line :
find user2 -ls | awk {if ($5 != $6) print $0 }

 
Code:
ls -ld * | awk '{if ($3==$4) print "find",$NF " -ls | awk '"'"'{if ($5 != $6) print $0 }'"'"'"}'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Simply great PHV, i often read your replies, and they are always accurate.
I can now go further.
Thanks !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top