need a command to search for numbers greater than 3000


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers need a command to search for numbers greater than 3000
# 1  
Old 03-30-2011
need a command to search for numbers greater than 3000

i have a file contains:

Code:
13213,A,300
3423,C,200
5563,A,201
3000,A,400
3000,A,402
3000,A,206
3000,A,303
3000,A,200
4233,N,204

i need to search for numbers in the first column are greater than 3000?

i have another issue if you can help me?
if i want to search in the second or the third columns what is the command that i can use to specify a specific column to search in .....
# 2  
Old 03-30-2011
Quote:
Originally Posted by takyeldin
i have a file contains:

Code:
13213,A,300
3423,C,200
5563,A,201
3000,A,400
3000,A,402
3000,A,206
3000,A,303
3000,A,200
4233,N,204

i need to search for numbers in the first column are greater than 3000?

i have another issue if you can help me?
if i want to search in the second or the third columns what is the command that i can use to specify a specific column to search in .....
For the 1st column:
Code:
awk -F, '$1 > 3000' file

Adjust the column number for other columns, $2 for the 2nd column, $3 for the 3th column and so on.
This User Gave Thanks to Franklin52 For This Post:
# 3  
Old 03-30-2011
thanks,

but i have another issue, i need to search in first column for numbers greater than 3000 then searching in the second column of the output for A or N then searching in the third column of the output for value starts with 2xx

i need the out put to be

Code:
5563,A,201
4233,N,204

# 4  
Old 03-30-2011
Code:
awk -F, '$1 > 3000 && $2 ~ /[AN]/ && $3 ~ /^2/ ' file

This User Gave Thanks to Franklin52 For This Post:
# 5  
Old 03-30-2011
I'm very happy Smilie

i'm sorry for asking alot but i'm new in unix world.

the last question please if i need to filter the first column with range starts from 2000 to 6000 instead of greater than 3000 condition
# 6  
Old 03-30-2011
Quote:
Originally Posted by takyeldin
I'm very happy Smilie

i'm sorry for asking alot but i'm new in unix world.

the last question please if i need to filter the first column with range starts from 2000 to 6000 instead of greater than 3000 condition
Code:
$1 >= 2000 && $1 <= 6000

This User Gave Thanks to Franklin52 For This Post:
# 7  
Old 03-30-2011
sorry i think you got me wrong, lets say that the file contains

0123318739,A,300,abcde
0120123456,C,200,xcvfe
0120453576,A,201,fgsa
0110445654,A,400,gcaz
0120432343,A,402,dewa
0129423,A,206,dea
0104323433,A,303,a
01232132134,A,200,a
0122344242,N,204,ghfs

i need from first column all numbers start from 01201xxxxx to 0122xxxxxx then from 2nd A or N then 3rd start with 2xx then 4th contains a (charcter)
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Search for columns with numbers greater than 70

This helped get me started. https://www.unix.com/unix-for-dummies-questions-and-answers/157026-need-command-search-numbers-greater-than-3000-a.html This is the command I am using. I am trying to find numbers greater than 70 in column 5. I do not know if it is getting confused because there... (6 Replies)
Discussion started by: cokedude
6 Replies

2. UNIX for Beginners Questions & Answers

Find command size greater than or equalto

How do I find the files greater than or equal to a given size using find command. find ./ -size +0k --> Lists files greater than 0K find ./ -size 0k --> Lists the file size equal to 0K. I have other conditions to check, hence using find command. Thanks in advance. (4 Replies)
Discussion started by: deepakwins
4 Replies

3. UNIX for Dummies Questions & Answers

Grep lines with numbers greater than 2 digits at the end of the line

I'm trying to grep lines where the digits at the end of each line are greater than digits. Tried this but it will only allow me to specify 2 digits. Any ideas would greatly be appreciated. grep -i '\<\{3,4,5\}\>' file ---------- Post updated at 05:58 PM ---------- Previous update was at 05:41... (1 Reply)
Discussion started by: jimmyf
1 Replies

4. Shell Programming and Scripting

How to search for numbers greater than x?

I have a file with multiple fields, example below File 1: Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|100 Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|101 Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|102 Field 1|Field 2|Field 3|Field 4|Field 5|Field... (4 Replies)
Discussion started by: castrojc
4 Replies

5. Shell Programming and Scripting

search file for value greater than 'n' on each line and email

Hi, I need to write a script that will read each line of a CSV file, look for values greater than x seconds and email an alert. For the first part, I have one CSV per day, each line in the CSV has comma separated values. There are a total of 8 fields per line separated by commas. 6th and 7th... (3 Replies)
Discussion started by: ssid
3 Replies

6. Shell Programming and Scripting

search column and delete row if greater than value

Hi, as the title states i need to find a way to search a column for values great than 1000, and if it is, then delete that row. An example 1 7.021 6.967 116.019 4 U 6.980E+07 0.000E+00 e 0 0 0 0 2 8.292 7.908 118.063 3 U 1.440E+07 0.000E+00 e 0 821 814 ... (3 Replies)
Discussion started by: olifu02
3 Replies

7. Homework & Coursework Questions

Problem with awk,not able print the file that is greater than 3000 bytes.

My Script: #!/bin/sh date=`date +%y%m%d -d"1 day ago"` in_dir=/vis/logfiles/to_solmis cp `grep -il ST~856~ $inbound_dir/*$date*` /vis/sumit/in_ASN/ for i in /vis/sumit/in_ASN/* do mkdir -p /vis/sumit/inboundasns.$date cp `echo $i`... (1 Reply)
Discussion started by: shrima.pratima
1 Replies

8. Shell Programming and Scripting

replacing numbers greater than 0 with 1

I have some ASCII files containing numerous numbers. What I'd like to do is replace all numbers greater than 0 with 1. Examples of the numbers include: - 000011 and 000042 Thanks (4 Replies)
Discussion started by: vrms
4 Replies

9. Shell Programming and Scripting

How to perform calculations using numbers greater than 2150000000.

Could someone tell me how to perform calculations using numbers greater than 2150000000 in Korn Shell? When I tried to do it it gave me the wrong answer. e.g. I have a ksh file with the contents below: --------------------------------- #!/bin/ksh SUM=`expr 2150000000 + 2` PRODUCT=`expr... (3 Replies)
Discussion started by: stevefox
3 Replies

10. UNIX for Advanced & Expert Users

how to remove line greater then 3000 characters.

I am using awk and it stops when it encounter line greater then 3000 character. Is there any command which will help me remove line greater then 3000 characters. (10 Replies)
Discussion started by: naren_14
10 Replies
Login or Register to Ask a Question