Quick help on 'awk' needed...!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Quick help on 'awk' needed...!!
# 1  
Old 12-01-2009
MySQL Quick help on 'awk' needed...!!

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
# 2  
Old 12-01-2009
What do you want to check in that if condition ?

tyler_durden
# 3  
Old 12-01-2009
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 Scott; 12-01-2009 at 05:16 PM..
# 4  
Old 12-02-2009
MySQL

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
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Quick awk question

gawk 'BEGIN{count=0} /^Jan 5 04:33/,0 && /fail/ && /09x83377/ { count++ } END { print count }' /var/log/syslog what is wrong with this code? i want to search the strings "fail" and "09x83377" from all entries. im grabbing all entries in the log starting from Jan 5 04:33 to the end of the... (3 Replies)
Discussion started by: SkySmart
3 Replies

2. Shell Programming and Scripting

Quick awk tip :)

how do i "awk" the date after the from only to compare it on a if statement later . filename example: server1-ips-ultranoob-ok_From_2012_21_12-23:40:23_To_2012_21_12-23:49:45.zip what i want o do is compare only the date from the string in "From_2012_21_12" in this case i only want the... (4 Replies)
Discussion started by: drd0spt
4 Replies

3. Shell Programming and Scripting

Quick Favour needed

Hi there, i currently dont have access to my linux machine and need to get these script files sent to someone. Can someone please create .sh files for me with the code that i have displayed below. It would be very very helpfull. There are 3 different scripts and it would be great if someone... (3 Replies)
Discussion started by: aLderzz
3 Replies

4. Shell Programming and Scripting

Notepad help needed easy quick question

TAKE A LOOK AT THE ATTACHED PICTURE. my goal is just to SELECT n DELETE Those lines : Dialogue: Marked=0,0:02:39.49,0:02:40.49,Default,NTP,0000,00 00,0000,!Effect, (without the text) take a look at that picture... the marked line... i just need ALL of these lines removed.. i managed... (3 Replies)
Discussion started by: mr_spidey
3 Replies

5. UNIX for Dummies Questions & Answers

Quick egrep / awk help, Please

Ok, this may be very simple but I can't find a solution. I have a list of numbered values which I have grepped from a larger life. ex/ 1:7.54 2:4.52 3:3.22 4:2.11 5:3.59 6:4.36 7:6.88 8:12.28 9:13.37 10:15.6 11:17.66 12:14.25 I need a quick way to organize them (using awk?)... (4 Replies)
Discussion started by: jdolny
4 Replies

6. UNIX for Advanced & Expert Users

Guidance needed for quick script

Hi all, I am trying to get the exception count daily from a log file which is more than 1 GB in size. I am using loops which get the count of the exception and transaction. But i need to take this exception count for a time frame from 5.00 am to 5:00 pm. I Think I can use to exact the... (4 Replies)
Discussion started by: senthilkumar_ak
4 Replies

7. Shell Programming and Scripting

Quick help needed in the Shell Script

Hiii, i have a doubt here-- I have to take backup of all the files inside directory dir(logs,tmp,corefiles) at the location $BackupLocation.i should take the backup of logs,tmp,corefiles inside the $BackupLocation directory and then remove the files and touch the files inside the directory... (1 Reply)
Discussion started by: namishtiwari
1 Replies

8. Shell Programming and Scripting

Help with AWK -- quick question

Ok. I'm just starting to use AWK and I have a question. Here's what I'm trying to do: uname -n returns the following on my box: ftsdt-svsi20.si.sandbox.com I want to pipe this to an AWK statement and make it only print: svsi20 I tried: uname -n | awk '{ FS = "." ; print $1 }' ... (5 Replies)
Discussion started by: Probos
5 Replies

9. IP Networking

IP Address changes - Quick Help Needed.

We are running Solaris 9 and I have changed the IP address, Subnet Mask & Broadcast Address using ifconfig and have also changed the default gateway. How do I save these changes as I have bounced the box and it reverted back to the old IP Address settings. I am really new to UNIX and we... (4 Replies)
Discussion started by: gingerd2003
4 Replies
Login or Register to Ask a Question