Sponsored Content
Top Forums Shell Programming and Scripting Can anyone tell me what's wrong with my script Post 302768779 by Don Cragun on Saturday 9th of February 2013 02:52:59 PM
Old 02-09-2013
Quote:
Originally Posted by Akshay Hegde
here I am attaching 2 files needs to be compared...first file2 needs to be compared with file1

condition is mentioned in if statements

Code:
c=`awk 'END{print NR}' file1.txt`
awk '{{getline< "file1.txt";ll[NR]=$1;lt[NR]=$2}}
FNR<=NR{
ll1=$1
lt1=$2
p=$2+0.1
m=$2-0.1
x=0
y=0
ct=ct+1
cc=$3
{
for(j=1;j<='$c';j++)
if(lt[j]>=m && lt[j]<=p)
{
if(ll1>=ll[j])
{x=x+1}
if(ll1<=ll[j])
{y=y+1}
}
}
if(x>=1 && y>=1)
{print ll1,lt1,"You are in"}
}' OFS="\t" file2.txt

this is printing data
but, data is not in file2, it was suppose to print data from file 2 I really don't know what mistake I am doing here....

pls explain if you find my mistake, I guess might be in array

output looks like this

Code:
68.14    23.48    You are in
67.62    23.04    You are in   ------->wrong 23.04 not exist in file2
67.68    23.09    You are in   -------> file1 data is printing
67.73    23.14    You are in   -------> again wrong result...
67.79    23.19    You are in
67.85    23.24    You are in
67.91    23.28    You are in
67.97    23.33    You are in
68.02    23.38    You are in
68.08    23.43    You are in
67.56    22.99    You are in
67.13    22.54    You are in

I agree with Jim. You make us download two files to see that you have one file with spaces as field separators and another file with a tab as the field separator. You give us some awk code that contains no comments and does not do what you want it to do. You tell us that the comments in the if statements explain what you're trying to do (but as I said, there are no comments in your code). You ask us to guess at what you mean by "2 files need to be compared". We can't read your code and tell you what is wrong with it if we don't know what you're trying to do.

Please tell us what you are trying to do in English. Show us sample input and show us the output you want from that sample input. Don't show us that your code doesn't give you what you want; show us what you do want.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

What is wrong with my script?

Hey guys, can someone help me with this script... #!/bin/sh dir=`pwd` for i in *.f do if then M=`wc -l < ${i} sed -e 's://.*::' < ${i} | \ (echo "//${i} -"$M ; cat - ) > $i.tmp chmod 700 $i ; mv ${i}.tmp $i ... (6 Replies)
Discussion started by: Lem2003
6 Replies

2. Shell Programming and Scripting

What is wrong with this script?

I keep getting errors messages for the "else" statement at line 81? #!/bin/ksh ######### Environment Setup ######### PATH=/gers/nurev/menu/pub/sbin:/gers/nurev/menu/pub/bin:/gers/nurev/menu/pub/mac :/gers/nurev/menu/adm/sbin:/gers/nurev/menu/adm/bin:/gers/nurev/menu/adm/mac:/ge... (8 Replies)
Discussion started by: heprox
8 Replies

3. Shell Programming and Scripting

What's wrong with this script

I am trying to create a script but it is giving me errors on Cygwin for the following script. Could someone tell me, what am I doing wrong? choice=1000 echo "choice is $choice" while ; do echo "choice is $choice" echo 'Please select your option:' echo '1. Option 1' echo '2. Option 2'... (3 Replies)
Discussion started by: amitg1980
3 Replies

4. UNIX for Dummies Questions & Answers

what is wrong with this script?

Hi, I have this example script which gives error ": unexpected operator/operand". I need the '' brackets for operator precedence. #!/bin/ksh x="abc" y="xyz" z="123" if -a then print "yes" else print "no" fi Thanks (2 Replies)
Discussion started by: rs1969
2 Replies

5. Shell Programming and Scripting

what is wrong with this script?

Hi I've made a short script but it is not working. Can some pl. help me out in this? ./123.sh #! /usr/bin/ksh # for changing to this directory cd /layered/relational/scripts When I run the above scripts, it doesn't change to the above directory. I don't what is the problem? the... (2 Replies)
Discussion started by: Mike1234
2 Replies

6. Shell Programming and Scripting

Script Gone Wrong

Hello all, so this is a script i did for an assignement, - first option greets the user according to the time after fetching his name - second options isn't implemented - third check the performance according to how many users are using the system - creates a log of names, time and ip of the... (14 Replies)
Discussion started by: ibzee33
14 Replies

7. Shell Programming and Scripting

What's wrong with my script ....

Please see below mentioned my script ... it ran once without any issue .... then after it is not coming out .... please suggest what is wrong? #!/bin/ksh ## if (( ${num_errors} > 0 )); export ACULOG=/home/varshnes/input export num_errors=10 **** Search for 'Start correcting roll up... (7 Replies)
Discussion started by: heyitsmeok
7 Replies

8. UNIX for Dummies Questions & Answers

What's wrong on this script?

I get this error on these lines when i run this script:"for i in /home;do file2=`ls -s $i` if ;then ls - s $i fi done (7 Replies)
Discussion started by: kotsos13
7 Replies

9. Shell Programming and Scripting

What is wrong with my script?

Dear All The following is part of my script: echo ${myarray} mytitle=`awk '{print substr(${myarray}, 0, length(${myarray})-4)}' /dev/null` the echo ${myarray} works fine; however, I keep getting following error for the mytitle=.. part: awk: line 1: syntax error at or near { awk: line... (3 Replies)
Discussion started by: littlewenwen
3 Replies

10. Shell Programming and Scripting

Why result is wrong here ? whether break statement is wrong ?

Hi ! all I am just trying to check range in my datafile pls tell me why its resulting wrong admin@IEEE:~/Desktop$ cat test.txt 0 28.4 5 28.4 10 28.4 15 28.5 20 28.5 25 28.6 30 28.6 35 28.7 40 28.7 45 28.7 50 28.8 55 28.8 60 28.8 65 28.1... (2 Replies)
Discussion started by: Akshay Hegde
2 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 08:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy