LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-24-2006, 03:46 AM   #1
sarajevo
Member
 
Registered: Apr 2005
Distribution: Debian, OpenBSD,Fedora,RedHat
Posts: 228
Blog Entries: 1

Rep: Reputation: 31
How sort data in some file which are greater than some value?


Hi people,

I would like to ask you something:
In some .txt folder I have many numbers, and using awk ' { print $2 , $3 ,....} ' I can filter data and write them to some directory. Some columns has data like below
2
3
4
5
6
10
11
12
13
my question is how filter data in this colone but only numbers greater or equal to 10 I mean >=10, ( 10, 11, 12, 13 ) and write them to some folder using redirection. Every hint is welcome.

Thanks in advance

Regards
 
Old 08-24-2006, 03:56 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
you could do it with an if statement in awk:
Code:
 awk '{(if $1>=10) print $1}' input.file > output.file

Last edited by pwc101; 08-24-2006 at 03:58 AM.
 
Old 08-24-2006, 04:28 AM   #3
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
grep [1-9][0-9] file >file2
 
Old 08-24-2006, 12:32 PM   #4
sarajevo
Member
 
Registered: Apr 2005
Distribution: Debian, OpenBSD,Fedora,RedHat
Posts: 228

Original Poster
Blog Entries: 1

Rep: Reputation: 31
Thank you.
 
Old 08-24-2006, 01:31 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912
Quote:
Originally Posted by /bin/bash
grep [1-9][0-9] file >file2
Unless of course >10 includes 100 + ;} ...


Cheers,
Tink
 
Old 08-25-2006, 03:48 AM   #6
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
Quote:
Unless of course >10 includes 100 + ;} ...
What do you mean?

$seq 90 2 110 >file;seq 1 12 >>file
$grep [1-9][0-9] file
90
92
94
96
98
100
102
104
106
108
110
10
11
12
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
some sort of data analyzer exkor5000 Linux - Software 2 07-07-2006 09:52 AM
How can I sort the lines in a file? windhair Linux - Software 2 11-17-2005 08:37 AM
Unix data sort question amytys Programming 2 07-01-2005 05:24 AM
Redhat Data Sort eivets Linux - Software 3 03-22-2005 02:52 PM
i can upload file that is greater than 1MB marconi8 Linux - General 0 12-17-2002 09:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration