Awk : find progressive increase in numbers


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Awk : find progressive increase in numbers
# 1  
Awk : find progressive increase in numbers

Code:
NR_037575	-0.155613339079513	-0.952655362767482	-1.42096466949375	-0.797042023687969	-1.26535133041424	-0.468309306726272
NR_037576	0.59124585320226	0.408702582537126	0.888885242203586	-0.182543270665134	0.297639389001326	0.480182659666459
NR_037577	0.59124585320226	0.408702582537126	0.888885242203586	-0.182543270665134	0.297639389001326	0.480182659666459
NR_037580	0.59124585320226	0.408702582537126	0.888885242203586	-0.182543270665134	0.297639389001326	0.480182659666459
NR_037582	-0.280359806872423	-0.094933876343707	-0.245718977134492	0.185425930528716	0.0346408297379309	-0.150785100790785
NR_037583	0.496940652036721	1.06221614526053	0.80679152307202	0.565275493223806	0.309850871035299	-0.255424622188507

Is there any way to find lines that have progressive increase of value

like

Code:
awk '{ if ( $2 >3 && $3>4 && $4>$5 && $5 >$6 ) {print "0"} }'

# 2  
corrected the syntax, try:

Code:
awk '{ if ( $2 > $3 && $3 > $4 && $4 > $5 && $5 > $6 ) {print "$0"} }' fileName

R0H0N
# 3  
Working fine. Thanx no need of answer ....

---------- Post updated at 03:46 AM ---------- Previous update was at 03:46 AM ----------

sorry did nt see ur answer
# 4  
Code:
awk '$2>$3 && $3>$4 && $4>$5 && $5>$6'  infile

# 5  
if the number of columns varied in different line, below perl may give you some clue.

Code:
sub same{
 my $ref=$_[0];
 $ref->();
 my @a=@{$_[1]};
 my @b = @{$_[2]};
 for (my $i=0;$i<=$#a;$i++){
  return 0 if $a[$i]!=$b[$i];
 }
 return 1;
}
while(<DATA>){
 my @tmp = split;
 my @arr = @tmp[1..$#tmp];
 my @t = sort {$b<=>$a} @arr;
 print $_ if same(sub{print "@arr -- @t\n";},\@arr,\@t);
}
__DATA__
leo 1 2 3 4 5
stt 3 4 5 6 7 8 9
duo 1 3 2 4 6 4 7 5
aaa 5 4 3 2

Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #163
Difficulty: Easy
MINIX was first released in 1987, with the complete source code available to universities for study in courses and research.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Increase the performance of find command.

I'm trying to exclude 'BACKUP', 'STORE', 'LOGGER' folders while searching for all files under a directory "/tmp/moht" Once a file is found I wish to display the filename, the size of the file & the cksum value. Below is the command, I'm using: /opt/freeware/bin/find /tmp/moht -type d -name... (6 Replies)
Discussion started by: mohtashims
6 Replies

2. UNIX for Beginners Questions & Answers

Script That Find Numbers Less Than 10

We have an existing script called "slots.sh" that prints a few numbers. I want to have another shell script that looks if there is any number from this output that is less than 10. If it does find a number that is less than 10, it then emails to me the output of "slot. sh", if it is equal to 10 or... (7 Replies)
Discussion started by: forextrafun
7 Replies

3. UNIX for Dummies Questions & Answers

Sed/awk to find negative numbers and replace with 1?

Greetings. I have a three column file, and there are some numbers in the second column that are <1. However I need all numbers to be positive, thus need to replace all those numbers with just one. I feel like there must be a simple way to use awk to find these numbers and sed to replace but can't... (5 Replies)
Discussion started by: Twinklefingers
5 Replies

4. UNIX for Dummies Questions & Answers

Find common numbers from two very large files using awk or the like

I've got two files that each contain a 16-digit number in positions 1-16. The first file has 63,120 entries all sorted numerically. The second file has 142,479 entries, also sorted numerically. I want to read through each file and output the entries that appear in both. So far I've had no... (13 Replies)
Discussion started by: Scottie1954
13 Replies

5. Shell Programming and Scripting

Find missed numbers

I have a file as follows: 1 3 7 12 78 ... 999998 1000000 I want to find out all numbers not in the file above and put into another file like 2 4 5 6 8 9 10 (13 Replies)
Discussion started by: dtdt
13 Replies

6. Shell Programming and Scripting

increase/decrease multiple numbers in a filename.

I got a game that output map tiles of the session with the 0,0 position at the place you login/spawn. That makes making a map somewhat troublesome since the 0,0 will move. So I've been looking for a way to change the numbers in the filenames of all files in a folder by a certain value. The... (5 Replies)
Discussion started by: Ravenholdt
5 Replies

7. Shell Programming and Scripting

AWK regex to find only numbers

Hi guys I need to find both negative and positive numbers from the following text file. And i also dont need 0. 0 8 -7 -2268 007 -07 -00 -0a0 0a0 -07a0 7a00 0a0 Can someone please give a regex to filter out the values in red. I tried a few things in awk but it didnt work... (9 Replies)
Discussion started by: sridanu
9 Replies

8. Solaris

How to increase Inode numbers in Solaris 10

Hi guys, need your help on this since i dont know much about solaris. the problem is i need to increase inodes space on /export/home/ root@BRF-DANCCM1 # /usr/ucb/df -i Filesystem iused ifree %iused Mounted on /dev/vx/dsk/bootdg/rootvol 53026 1162206 ... (7 Replies)
Discussion started by: ichiko
7 Replies

9. Shell Programming and Scripting

to find numbers in a string

I writing my script and got stuck in this function. Can someone help me? I need to extract out the numbers inside a string. Ex: INPUT -> OUTPUT abcdef123 -> 123 abc123def -> 123 123abcdef -> 123 a123bc45d -> 123 45 abcdefghi -> -1 Thank you! (12 Replies)
Discussion started by: fongthai
12 Replies

10. Shell Programming and Scripting

to find numbers using awk

suppose u have a file 23 33 44 66 55 88 Another file 49 34 49 90 So to find where these numbers lie between in the first file output shud be while using second file and search for the first file 44 66 - 23 33 44 66 - (1 Reply)
Discussion started by: cdfd123
1 Replies

Featured Tech Videos