Zsh : for loop makes failing awk pattern -


i’m writing scripts manage users specifics quotas on server.

so, apply quota 10gb users in group quota10, i’m using "setquota -p", have several groups.

so made script manage users groups.

#!/bin/zsh groups=(1002 1007) gid in $groups     echo $gid     echo $(awk -f: '$4 == gid {print $1}' gid=$gid /etc/passwd) 

but when execute it, there last group give me users in group.

/etc/passwd

kimino:x:1010:1002::/home/kimino:/bin/bash kiminoo:x:1011:1007::/home/kiminoo:/bin/bash 

/etc/group

quota10:x:1002: quota20:x:1007: 

output of script

# ./apply_quota_on_users.zsh 1002 1007 kiminoo 

do have idea what’s wrong ?

you have wrap functions in block:

for gid in $groups     echo $gid     echo $(awk -f: '$4 == gid {print $1}' gid=$gid /etc/passwd) done 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -