awk RS/ORS error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk RS/ORS error
# 8  
Old 03-09-2016
Hmm, it seems I can understand individual line of your script, but not the whole logic. Can you comments my catch:

1) The first line /^@/ && m && c > .6 {printf m;} is used for previous record that has been scanned in the loop. For example, the first record (if its c > 0.6) of the input.file is not printed until the second record has been scanned. Am I right?
2) The END {if (m && c > .6) printf m;} block is only for the last record in the case the sequence has c>=0.6, right?

At first I thought m is for all the records and stored in the memory, which would slow down the process quite bit I guess. With a file of 10GB of size, your script still works as fast like the other one without any RAM issue, which brought me to confirm my understanding.

Last edited by yifangt; 03-10-2016 at 12:27 PM..
# 9  
Old 03-09-2016
1) yes. the previous record is stored in variable m
2) yes.
This User Gave Thanks to rdrtx1 For This Post:
# 10  
Old 03-09-2016
It was hard for me at first.
Thanks a lot!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Can someone please explain why we need to set ORS in below awk code?

Question: Write a command to print the fields in a text file in reverse order? awk 'BEGIN {ORS=""} { for(i=NF;i>0;i--) print $i," "; print "\n"}' filename I was thinking it should be (what is the need to set ORS="" ? )- awk 'BEGIN { for(i=NF;i>0;i--) print $i," "; print "\n"}' filename (3 Replies)
Discussion started by: Tanu
3 Replies

2. Shell Programming and Scripting

awk : ORS not to be printed after the last record

Hello Team, here is the code: scripts]# ls /etc/init.d/ | awk 'BEGIN{ORS=" && "} /was.init/ && !/interdependentwas/ && !/NodeAgent/ && !/dmgr/{print "\$\{service_cmd\} "$0 " status"}' 2>/dev/null ${service_cmd} cmserver_was.init status && ${service_cmd} fmserver_was.init status &&... (6 Replies)
Discussion started by: chandana.hs
6 Replies

3. UNIX for Dummies Questions & Answers

No error in awk...

Hi all... In the OSX forum I am starting a new awk project to learn awk. In this code snippet I have had to check boundaries to ensure that no NUMERICAL error occurs in the rest of the code... printf "Enter frequency required:- "; getline FREQ; RATE=(BYTES*FREQ); if ( RATE <= 4000 ) {... (4 Replies)
Discussion started by: wisecracker
4 Replies

4. Shell Programming and Scripting

awk output yields error: awk:can't open job_name (Autosys)

Good evening, Im newbie at unix specially with awk From an scheduler program called Autosys i want to extract some data reading an inputfile that comprises jobs names, then formating the output to columns for example 1. This is the inputfile: $ more MapaRep.txt ds_extra_nikira_usuarios... (18 Replies)
Discussion started by: alexcol
18 Replies

5. Shell Programming and Scripting

awk error

Hi Team, I have .csv file in the following format .csv file TAB1;COL1;DATATYPE;NOTNULL;WITH DEFAULT TAB2;COL1;DATATYPE;NOTNULL;WITH DEFAULT .... .... .... output: ALTER TABLE TAB1. add COL1 DATATYPE NOTNULL WITH DEFAULT; ALTER TABLE TAB2 add COL1 DATATYPE NOTNULL WITH DEFAULT; I... (5 Replies)
Discussion started by: rocking77
5 Replies

6. Shell Programming and Scripting

awk command in script gives error while same awk command at prompt runs fine: Why?

Hello all, Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val: > cat getnon0file.sh #!/bin/bash this="getnon0file.sh" USAGE=$this" InFile="xyz.38" Min="0.05" # awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Discussion started by: catalys
4 Replies

7. Shell Programming and Scripting

Awk error -- awk: 0602-562 Field $() is not correct.

typeset -i i=1 while read -r filename; do Splitfile=`$Targetfile_$i.txt` awk 'substr($0,1,5) == substr($filename,1,5) && substr($0,526,2) == substr($filename,6,2) && substr($0,750,12) == substr($filename,8,12)' $SourceFilename >> $Splitfile i=i+1 done < /tmp/list.out I am using this logic... (1 Reply)
Discussion started by: pukars4u
1 Replies

8. UNIX for Dummies Questions & Answers

awk Shell Script error : "Syntax Error : `Split' unexpected

hi there i write one awk script file in shell programing the code is related to dd/mm/yy to month, day year format but i get an error please can anybody help me out in this problem ?????? i give my code here including error awk ` # date-month -- convert mm/dd/yy to month day,... (2 Replies)
Discussion started by: Herry
2 Replies

9. Shell Programming and Scripting

Error in awk

var1=`echo "emp,dept,salgrade" | awk -F, '{print NF}'` count=1 while ; do i=`expr $count` tname=`echo "emp,dept,salgrade" | awk -F, '{ print $(echo $i) }'` count=$count+1; echo ${tname}; echo $count done I want to store in tname=emp, tname=dept,tname=salgrade I am getting... (2 Replies)
Discussion started by: dreams5617
2 Replies

10. Shell Programming and Scripting

rs and ors in gawk ...????

:D dear members I have a good knowledge of gawk and seem to do quite well with it.. but I have never understood what the use of the rs and ors are for or how they are used.. i am thinking they are for seperating lines and paragraphs but i have absolutely no idea how to make it work, if that is what... (2 Replies)
Discussion started by: moxxx68
2 Replies
Login or Register to Ask a Question