awk script creates empty line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk script creates empty line
# 1  
Old 08-09-2011
awk script creates empty line

I have the following awk script to which I pass the file

Code:
>
10 0 0
10 0 0
>
12.997 0 5.71132
12.9098 0.0687626 5.48855
12.7506 0.174324 5.13225
12.5913 0.262662 4.80643
12.4316 0.335652 4.50283
12.2717 0.394598 4.21542
12.1113 0.440399 3.93957
11.9506 0.473646 3.67148
11.7894 0.494683 3.40796
11.6282 0.507873 3.14655
11.4668 0.513264 2.88568
11.3052 0.51083 2.62412
11.1435 0.500489 2.35993
10.9812 0.477519 2.08919
10.8186 0.441218 1.80796
10.6554 0.390541 1.51136
10.4919 0.323966 1.19278
10.328 0.239269 0.842665
10.164 0.133085 0.445932
10 0 0
>
16.009 0 10.1626
15.8903 0.126154 9.82264
15.7561 0.251092 9.49599
15.6221 0.36099 9.20265
15.4881 0.457904 8.9338
15.3551 0.546561 8.68121
15.222 0.628172 8.44012
15.0889 0.703183 8.20893
14.9557 0.771971 7.98627
14.8225 0.834852 7.77101
14.6893 0.892098 7.56215
14.556 0.943939 7.35884
14.4226 0.99057 7.16023
14.2893 1.03281 6.96536
14.1559 1.07079 6.77367
14.0224 1.1046 6.58474
13.8889 1.13432 6.39818
13.7553 1.16002 6.21362
13.6217 1.18175 6.03072
13.488 1.19956 5.84915
13.3543 1.21348 5.66858
13.2205 1.22353 5.48873
13.0867 1.22973 5.30928
12.9528 1.23209 5.12993
12.8189 1.23059 4.9504
12.6849 1.22523 4.77038
12.5508 1.21597 4.58956
12.4167 1.20279 4.40763
12.2825 1.18563 4.22426
12.1483 1.16445 4.03911
12.0141 1.13916 3.85182
11.8797 1.1097 3.66199
11.7453 1.07596 3.46921
11.6109 1.03783 3.27297
11.4766 0.994523 3.07251
11.3422 0.94577 2.86665
11.2077 0.891331 2.65453
11.0732 0.83092 2.43511
10.9387 0.7642 2.2072
10.8041 0.690768 1.96937
10.6694 0.610147 1.71989
10.5348 0.521758 1.45468
10.4006 0.420012 1.16284
10.2666 0.302061 0.832405
10.1329 0.164111 0.445932
10 0 0
>

Code:
function abs(val) { return val > 0 ? val : -val }

BEGIN {
  print ">"
  RS = ORS = ">"
}

NF > 2 { if (abs($1 - $(NF-2)) < dsrmx) { print } }

When I run
Code:
awk -v dsrmx=65 -f ./rm-srdist-ry.awk test.ry > result

result contains a blank line in line 2. Can't understand why it gets created.

Code:
>

10 0 0
10 0 0
>
12.997 0 5.71132
12.9098 0.0687626 5.48855
12.7506 0.174324 5.13225
12.5913 0.262662 4.80643
12.4316 0.335652 4.50283
12.2717 0.394598 4.21542
12.1113 0.440399 3.93957
11.9506 0.473646 3.67148
11.7894 0.494683 3.40796
11.6282 0.507873 3.14655
11.4668 0.513264 2.88568
11.3052 0.51083 2.62412
11.1435 0.500489 2.35993
10.9812 0.477519 2.08919
10.8186 0.441218 1.80796
10.6554 0.390541 1.51136
10.4919 0.323966 1.19278
10.328 0.239269 0.842665
10.164 0.133085 0.445932
10 0 0
>
16.009 0 10.1626
15.8903 0.126154 9.82264
15.7561 0.251092 9.49599
15.6221 0.36099 9.20265
15.4881 0.457904 8.9338
15.3551 0.546561 8.68121
15.222 0.628172 8.44012
15.0889 0.703183 8.20893
14.9557 0.771971 7.98627
14.8225 0.834852 7.77101
14.6893 0.892098 7.56215
14.556 0.943939 7.35884
14.4226 0.99057 7.16023
14.2893 1.03281 6.96536
14.1559 1.07079 6.77367
14.0224 1.1046 6.58474
13.8889 1.13432 6.39818
13.7553 1.16002 6.21362
13.6217 1.18175 6.03072
13.488 1.19956 5.84915
13.3543 1.21348 5.66858
13.2205 1.22353 5.48873
13.0867 1.22973 5.30928
12.9528 1.23209 5.12993
12.8189 1.23059 4.9504
12.6849 1.22523 4.77038
12.5508 1.21597 4.58956
12.4167 1.20279 4.40763
12.2825 1.18563 4.22426
12.1483 1.16445 4.03911
12.0141 1.13916 3.85182
11.8797 1.1097 3.66199
11.7453 1.07596 3.46921
11.6109 1.03783 3.27297
11.4766 0.994523 3.07251
11.3422 0.94577 2.86665
11.2077 0.891331 2.65453
11.0732 0.83092 2.43511
10.9387 0.7642 2.2072
10.8041 0.690768 1.96937
10.6694 0.610147 1.71989
10.5348 0.521758 1.45468
10.4006 0.420012 1.16284
10.2666 0.302061 0.832405
10.1329 0.164111 0.445932
10 0 0
>

# 2  
Old 08-09-2011
Hi, the first record is :
Code:
10 0 0
10 0 0

The first line is the carriage return right after ">" of line 1 of the input file
# 3  
Old 08-09-2011
I do not want a blank line like that.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to identify empty fields in line

I am trying to use awk to identify and print out records in fields that are empty along with which line they are in. I hope the awk below is close, it runs but nothing results. Thank you :). awk awk -F'\t' 'FNR==NR ~ /^*$/ { print "NR is empty" }' file file 123 GOOD ID 45... (3 Replies)
Discussion started by: cmccabe
3 Replies

2. HP-UX

@ typing creates new line

Dear Concern, Please go through the article https://www.unix.com/hp-ux/134072-typing-sign-creates-new-line.html As per the article, we need to initiate below commands. But after creating new session, we face same problem. Please advise. stty intr "^c" stty kill "^u" Please find below... (6 Replies)
Discussion started by: makauser
6 Replies

3. UNIX for Dummies Questions & Answers

Using awk to remove duplicate line if field is empty

Hi all, I've got a file that has 12 fields. I've merged 2 files and there will be some duplicates in the following: FILE: 1. ABC, 12345, TEST1, BILLING, GV, 20/10/2012, C, 8, 100, AA, TT, 100 2. ABC, 12345, TEST1, BILLING, GV, 20/10/2012, C, 8, 100, AA, TT, (EMPTY) 3. CDC, 54321, TEST3,... (4 Replies)
Discussion started by: tugar
4 Replies

4. Shell Programming and Scripting

awk :quick question removing empty line.

How to write in awk to remove lines starting with "#" and then process the file: This is not working: cat file|awk '{if ($0 ~ /^#/) $0="";print NF>0}' When I just give cat file|awk '{if ($0 ~ /^#/) $0="";print }' it prints the blank lines . I don't wnat the blank lines along with the... (15 Replies)
Discussion started by: rveri
15 Replies

5. UNIX for Dummies Questions & Answers

Redirection creates empty file

I'm using a script that does some modifications to data on disc and updates the database. The script (perl) uses STDOUT so the results are printed to the screen. I don't have permissions to modify the script. I want to capture the results in a file so I can see if errors occurred and also keep... (3 Replies)
Discussion started by: surib
3 Replies

6. Shell Programming and Scripting

Script sometimes creates an empty file

I have a script that runs ditto for me, and occasionally (if I exit the script while ditto is running in the background) it will leave an empty file named 0 in the script's directory. The next time I run the script, it generates incorrect data because of this file. I know I can easily insert a... (1 Reply)
Discussion started by: reid
1 Replies

7. Shell Programming and Scripting

Script sometimes creates an empty file

I have a script that runs ditto for me, and occasionally (if I exit the script while ditto is running in the background) it will leave an empty file named 0 in the script's directory. The next time I run the script, it generates incorrect data because of this file. I know I can easily insert a... (1 Reply)
Discussion started by: reid
1 Replies

8. Shell Programming and Scripting

awk print last line returns empty string

hello I have a file with lines of info separated with "|" I want to amend the second field of the last line, using AWK my problem is with geting awk to return the last line this is what I am using awk 'END{ print $0 }' myFile but I get an empty result I tried the... (13 Replies)
Discussion started by: TasosARISFC
13 Replies

9. Shell Programming and Scripting

awk - if field is empty, move line to new file

I have a script with this statement: /usr/xpg4/bin/awk -F"" 'NR==FNR{s=$2;next}{printf "%s\"%s\"\n", $0, s}' LOOKUP.TXT finallistnew.txt >test.txt I want to include logic or an additional step that says if there is no data in field 3, move the whole line out of test.txt into an additional... (9 Replies)
Discussion started by: scriptr2be
9 Replies
Login or Register to Ask a Question