awk is reaing the file only once..PLZ help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk is reaing the file only once..PLZ help
# 1  
Old 09-22-2010
awk is reaing the file only once..PLZ help

This script needs to find the uniq values.
but only the 1st 10 are being shown...the next 10 are fairly neglected

Code:
#!/bin/bash  
exec<test.dat
x=10
value=0
while [ $value -le 1000 ] 
do
value=`expr $value + 1`;
#echo $value;
val=`expr $value % $x`;
if [ $val -eq "0" ]
then
awk -v f="$value"  '( NR<=f){print $0}'| grep -oP '\d{4,}' | sort -nu|wc -l
x=`expr $x + 10`;
echo $x
fi
#echo $value
done


Last edited by pludi; 09-22-2010 at 12:57 PM.. Reason: code tags, please...
# 2  
Old 09-22-2010
Of course it reads them only once. You re-open stdin to read from a file, and awk reads the whole of it in one go. Afterward, reading from stdin will always return EOF, unless it is again re-opened. Exiting awk as soon as your condition isn't true anymore might help.

Anyways, it looks like an overly complicated way to do what you want, and based on your IP address you might consider posting here instead.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Plz help me out use OFMT operator in awk programming

Hi While calculating the sum of 6 and 7 fileds it is calculate the wrong value because of floating point like 7898778.10 awk ' BEGIN { FS = OFS = "|" } NR == 1 { next } { UX = $1 OFS $3 OFS $4 OFS $5 p1 +=$6 p2 +=$7 } END { for(i in UX) ... (8 Replies)
Discussion started by: jagu
8 Replies

2. Shell Programming and Scripting

plz, i wait your help, AWK problem

I have tracefile of three nodes (0 , 1 and 2 ) as follows: + 0.02 0 1 tcp 40 ------- 1 0.0 2.0 0 0 - 0.02 0 1 tcp 40 ------- 1 0.0 2.0 0 0 + 0.02 2 1 tcp 40 ------- 2 2.1 0.1 0 1 - 0.02 2 1 tcp 40 ------- 2 2.1 0.1 0 1 r 0.025032 0 1 tcp 40 ------- 1 0.0 2.0 0 0 + 0.025032 1 2 tcp 40 -------... (11 Replies)
Discussion started by: ASAADAOUI
11 Replies

3. Shell Programming and Scripting

Reading Awk lines into variables help plz

I have output from luxadm display commands as below :- DEVICE PROPERTIES for disk: /dev/rdsk/c10t60020F200000C8083F951F4C00012863d0s2 Vendor: SUN Product ID: T300 Revision: 0201 Serial Num: Unsupported Unformatted capacity:... (0 Replies)
Discussion started by: lavascript
0 Replies

4. Shell Programming and Scripting

Explain this AWK script plz

Hi frnds, one my frnds has given resolution for my problem as below. it working great , but i couldnt understand somethings in the script. Why ++ operator after the function calling. how these each block working. will each run for each input line sequencially or one block for all the lines... (9 Replies)
Discussion started by: Gopal_Engg
9 Replies

5. Ubuntu

File opening prob. plz assist guys

Hi friends, this problem is pretty similar to the thread that i have generated earlier. If the TXT file that i have opened using "cat" is huge then my putty can only show me last few lines. Similarly if i use "more" command to open a huge TXT file then it asks to press any key to scroll up the... (9 Replies)
Discussion started by: anushree.a
9 Replies

6. Shell Programming and Scripting

plz help in writing awk script

hi buddies pls help in this matter i have file like this input file -------------------------- (PARTITION PARTITION_1 VALUES LESS THAN (101, 16383 ) TABLESPACE PART_1 ,PARTITION PARTITION_2 VALUES LESS THAN (101, 32766 ) TABLESPACE PART_2 ,PARTITION PARTITION_3 VALUES LESS THAN (101,... (3 Replies)
Discussion started by: LAKSHMI NARAYAN
3 Replies

7. Shell Programming and Scripting

help in writing awk script, plz urgent

I have a file like this I have to I have input file this , I want to give the out put in the below input file (NARAYANA 1 ENDING AT (100, 16383) ,NARAYANA 2 ENDING AT (100, 32766) ,NARAYANA 3 ENDING AT (100, 49149) ,NARAYANA 4 ENDING AT (100, 65535) ,NARAYANA 5... (8 Replies)
Discussion started by: LAKSHMI NARAYAN
8 Replies

8. Shell Programming and Scripting

Read string from a file,plz help me to check

#!/usr/bin/ksh exec 0<property while read newReceiveDir do if then sed -e 's//home/joshua/bodi/data/receive/{$newReceiveDir:25}/g/' mp_validate.sh >| mp_validate.sh elif then sed -e 's//home/joshua/bodi/data/temp/{$newReceiveDir:22}/g/' mp_validate.sh >| mp_validate.sh ... (1 Reply)
Discussion started by: joshuaduan
1 Replies

9. Shell Programming and Scripting

Plz Help To convert xml file to text file using bourn shell scripts

If someone out there could help me out with this problem. I would really appreciate it. I am trying to convert xml into text file(fixed length) using Unix Borne shell scripts. My xml file: <root> <header_rec recordtype="00"> <record_id>00</record_id> <country_code>AK></country_code>... (0 Replies)
Discussion started by: ram2s2001
0 Replies

10. UNIX for Dummies Questions & Answers

plz Help How should I configure cc compiler output file plz help???

i.e configuration of C compiler :confused: (4 Replies)
Discussion started by: atiato
4 Replies
Login or Register to Ask a Question