Sponsored Content
Top Forums Shell Programming and Scripting Can anyone tell me what's wrong with my script Post 302768783 by Akshay Hegde on Saturday 9th of February 2013 03:11:44 PM
Old 02-09-2013
Hammer & Screwdriver Logic I want to use in awk script

Code:
I just want to use this logic in shell awk script

1 . First read column 1 and column 2 of file1.txt store it in array(reference)

2 . Now read column 1 and column 2 of file2.txt store it in another array,to be compared with reference 

3 . for loop : - for(i=1;i<=file2.txt_length;i++)

4 . x=0; y=0 this will get clear as and when i will increment

5 . nested loop :-  for(j=1;j<=file1.txt_lenght;j++)

6 . if(col1_f1[j]>=col1_f2-0.1[i] && col1_f1[j]<=col1_f2+0.1[i])

if above if statement is true then,go to following statement else check condition with j++

7 . if(col2_f2[i]>=col2_f1[j]) then x=x+1

8 . if(col2_f2[i]<=col2_f1[j]) then y=y+1

repeat 5,6,7 and 8 till j reaches file1.txt_length(NR),Once j reaches NR following

9 . if(x>=1 && y>=1) then print column1_f2[i] column2_f2[i] 

repeat statements after number 4 to 9 till i reaches file2.txt_length(NR)

I hope this will be helpful

this logic is to find whether file 2.txt is falling within the range of file1.txt(reference)
if falling, how many records are near to records of file1.txt

and this is for mapping purpose, one can see script's result preview in GMT, with reference file

I am trying to write the same logic in awk script, but I couldn't succeed..those who know...awk very well pls help

Thanks in advance.........................

Last edited by Akshay Hegde; 02-10-2013 at 09:53 AM.. Reason: ???? Awaiting for reply......
 

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
set_color(1)							       fish							      set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 08:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy