![]() |
|
|
grep unix.com with google
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Our Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
Code:
bash-2.05$ A=`cat /etc/group |awk -F':' '{if ($1$3$4 == "tech111t7594as,t7656r0,t1653bk,t7161ps,t2399mt,t0055kb,t6990hp,t8112ra,t7121s1,t4269ct,t1450sl,t0752ps,t3008at,t2634cz,t7705sa,t5409jj,t1922dk,t4666vd,t9330sp,t4084a0,t8737dj,t9315gr,t5182jb,t5183r1,t5107jp,t4958cw,t3778n0,t0096pg,t1917sm,t5442sk,t5441ss,t1921yv,t6043pp,t6899bs,t6206dm,t6109sg,t5193gg,t1920pb,t1194mi,t6240pk,t0230pk,t5570kn,t5194rj,t4349sv,t4687ac,t6392ar,t6202rs,t1705aj,t1707rd,t1704lt,t2669sd,t3701ys,t8751ar,t4302kd,t4337rs,t3497rl,t2147am,t0054pd,t8780r2,t8779ab,t1449d0,t7219jc,t6227tr,t0467jk,t9649ri,t9452bj,t9921vk,t3434em,t0894s0,t6255bk,t6844bb,t5237sm,t7988s1,t7708hp,t1919jb,t2483eb,t1563dr,t6658pb,t9669sk,t9585cs,t5079ad,t2380lr,t6019r0,t2889r1,t0484tn,t5194m0,t9993ra,t5277gl,t0022uc,t0015vd,t9256rl,t2885rt,t2884wr,t3543ba,t2421tl,t0856mm,t2468m0,t1354gf,t3430sy,t2378kk,t1917r0,t1815vm,t0121ng,t0023pb,t7220ds,t9466br,t0047dw,t0272sk" ) print $1}'|sort|uniq`
awk: string too long near line 1
awk: syntax error near line 1
awk: illegal statement near line 1
Any idea how to accumulate all of the string in variable A? Regards Abhi |
|
|||
|
I'm reading between the lines, but do you want to put the group members into a variable based on the group name and group ID? i.e. Code:
A=$(awk -F: '$1$3 == "tech111" {print $NF}')
If not then how many servers do you have where exactly this number of members were added to that group in exactly that order? Last edited by scottn; 12-01-2009 at 05:16 PM.. |
|
|||
|
i'll reframe my problem...this should be easy to debug ... Code:
bash-3.00$ A=`cat /etc/group|awk -F: '{if ($1$3 == "secur138"){print $NF}}'|sort|uniq`
bash-3.00$ echo $A
t9330sp,t0096pg,t6899bs,t2483eb,t1563dr,t6658pb t9330sp,t0096pg,t6899bs,t2483eb,t1563dr,t6658pb,smadmn,sysweb,root
See that green colored string....rest all strings(or members) are comma separated....whereas this string is not..it should have been t6658pb,t9330sp... and its happening because Code:
bash-3.00$ cat /etc/group|awk -F: '{if ($1$3 == "secur138"){print $NF}}'
t9330sp,t0096pg,t6899bs,t2483eb,t1563dr,t6658pb
t9330sp,t0096pg,t6899bs,t2483eb,t1563dr,t6658pb,smadmn,sysweb,root
i have two groups defined with same name and id ,but few diffrent members.... My code looks like following to capture these comma separated strings: Code:
Host etcGroup DUP:
cat /etc/group | awk -F':' '{print $1$3}'|sort|uniq
Userlist:
A=`cat /etc/group|awk -F: '{if ($1$3 == "@@Host etcGroup.DUP@@") {print $NF}}'|sort|uniq`
B=`echo $A|wc -w`
if [ $B = 0 ]
then
echo NULL
else
count=`echo $A| nawk -F, {'print NF'}`
i=1
while [ $i -le $count ]
do
str[$i]=`echo $A| cut -d, -f${i}`
echo "${str[$i]}"
i=`expr $i + 1`
done
fi
any ideas? Regards Abhi |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Quick Favour needed | aLderzz | Shell Programming and Scripting | 3 | 07-27-2009 11:49 AM |
| Guidance needed for quick script | senthilkumar_ak | UNIX for Advanced & Expert Users | 4 | 08-08-2008 07:59 AM |
| Help needed in 'awk' : pls. | satyam_sat | Shell Programming and Scripting | 3 | 04-05-2008 02:36 PM |
| Quick help needed in the Shell Script | namishtiwari | Shell Programming and Scripting | 1 | 02-01-2008 09:44 AM |
| IP Address changes - Quick Help Needed. | gingerd2003 | IP Networking | 4 | 02-22-2007 11:39 AM |