How to Display a range of values in the output of cat


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to Display a range of values in the output of cat
# 1  
Old 05-11-2007
How to Display a range of values in the output of cat

When I use this command I get an output of some numbers
cat ac.20070511 | cut -d" " -f19

Is there any way for me to display only the numbers that are greater than 1000 but not all the numbers in the ouput.

Can any one help me with this. Smilie
# 2  
Old 05-11-2007
what's about:

awk '$19>999 {print $19}' ac.20070511

gP
# 3  
Old 05-11-2007
Venu, as always, there are several ways to solve a problem.
This is one of them using part of your solution:
Note there are four dots inside of single quote.
Code:
cut -d" " -f19 input_file | egrep '....'

# 4  
Old 05-11-2007
Pressy,

Yours should be working but the problem I have is in the output i have "12345" format. How can I eliminate "" so that i can check for the condition.
# 5  
Old 05-11-2007
Shell,

That one was good but it filters by number of digits, but if I need those greater than 15000 only then I think it might not work. Anyway thanks for that.
# 6  
Old 05-11-2007
ok...
Smilie
# sed 's/"//g' ac.20070511 | awk '$19>999 {print $19}'

gP
# 7  
Old 05-11-2007
Venu,
The "sed" that I wrote works for what you asked for:
Quote:
Is there any way for me to display only the numbers that are greater
than 1000 but not all the numbers in the ouput.
Now you are changing the requirement:
Quote:
...but if I need those greater than 15000 only...
There is no way one can write a solution that works after the
initial requirement changes.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Display files within a range

My script reads all the log files in a directory, the user would enter a range and the script would only display the files within those range. Here's my code: #!/bin/bash LOG_FILES=("Sandbox/logs/*") for file in ${LOG_FILES}; do echo $file; done ------------- for i in $(seq $1 $2); do... (1 Reply)
Discussion started by: Loc
1 Replies

2. Shell Programming and Scripting

Create range of values and count values.

Gents, It is possible to generate a range of values according to column 1 and count the total of rows in the range. example input 15.3 15.5 15.8 15.9 16.0 16.1 16.8 17.0 17.5 18.0 output desired 15.0 - 15.9 = 4 (10 Replies)
Discussion started by: jiam912
10 Replies

3. Shell Programming and Scripting

Find values within range and output

Dear All, I am stacked and I ask for your help. Briefly, I have two files, one like this one (file1): 1 101 5 1 102 6 1 103 2 1 104 9 1 105 10 2 301 89 2 302 4 2 303 13 2 304 34 2 305 1 and the other like this one (file2): 1 103 2 303well, what I am trying to do is obtain a... (2 Replies)
Discussion started by: giuliangiuseppe
2 Replies

4. Shell Programming and Scripting

Convert Column Values to a Range of Values

I have a list of columns with values that I need to transform into a row containing the range of each column. For example: "Column A" 1 2 3 4 10 12 14 15 16 17 18 "Column B" 1 4 5 6 (4 Replies)
Discussion started by: newbio
4 Replies

5. UNIX for Dummies Questions & Answers

Using ls command to display files for range of values only

Hi Forum. I tried to search the forum for an answer but couldn't find it. I have the following files in my directory: PROFILE_TXN_61647.dat PROFILE_TXN_61648.dat PROFILE_TXN_61649.dat PROFILE_TXN_61650.dat PROFILE_TXN_61651.dat PROFILE_TXN_61652.dat PROFILE_TXN_61653.dat... (8 Replies)
Discussion started by: pchang
8 Replies

6. Shell Programming and Scripting

Script with ^M causes display issue with cat or more

I have a script to do a couple simple but repetitive commands on files that are provided to us. One of the things is to get rid of the line feeds. This is the section that is causing problems, i even cut this section into its own file to make sure nothing else was affecting it. #!/usr/bin/bash... (4 Replies)
Discussion started by: oly_r
4 Replies

7. UNIX for Dummies Questions & Answers

How to display lines by range specified?

My input file is N3*123 ABC FLATS~ REF*D9*10000000001~ N3*223 ABC FLATS~ REF*D9*10000000002~ N3*323 ABC FLATS~ REF*D9*10000000003~ N3*423 ABC FLATS~ REF*D9*10000000004~ N3*523 ABC FLATS~ REF*D9*10000000005~ N3*623 ABC FLATS~ REF*D9*10000000006~ N3*723 ABC FLATS~ REF*D9*10000000007~ N3*823... (2 Replies)
Discussion started by: nsuresh316
2 Replies

8. Shell Programming and Scripting

Cat Values from Several files if it meets criteria for column values

I have results from some statistical analyses. The format of the results are as given below: I want to select lines that have a p-value (last column) less than 0.05 from all the results files (*.results) and cat to a new results file. It would be very nice if a new column is added that tells... (2 Replies)
Discussion started by: genehunter
2 Replies

9. Shell Programming and Scripting

Display variables in CAT area

Hi All, I've got a script to output YAML data, and I want to display data that's held inside variables inside one large CAT area. What's the easiest way to do this? cat << "END" --- classes: - general_image - $intro #Variable 1 - $mid #Variable 2 ... (2 Replies)
Discussion started by: glarizza
2 Replies

10. UNIX for Dummies Questions & Answers

using cat and grep to display missing records

Gentle Unix users, Can someone tell me how I can use a combination of the cat and grep command to display records that are in FileA but missing in FileB. cat FileA one line at a time and grep to see if it is in fileB. If it is ignore. If line is not in fileB display the line. Thanks in... (4 Replies)
Discussion started by: jxh461
4 Replies
Login or Register to Ask a Question