Filter and delete numbers in a list


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filter and delete numbers in a list
# 1  
Old 11-05-2017
Filter and delete numbers in a list

Hello,

I've got a list of a single column numbers like

Code:
3000.66
3002.55
3062.23
3242.12

etc...



I would like to delete all numbers higher than for example 3060.00 and lower
than 2990.00

How can I do that?

Thanks in advance

Last edited by rbatte1; 11-06-2017 at 09:56 AM.. Reason: Corrected Case and added CODE/ICODE tags
# 2  
Old 11-05-2017
Try:
Code:
awk -v min=2990 -v max=3060 '$1>=min && $1<=max' file

This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 11-05-2017
Code:
perl -nle 'print if ($_ <= 3060.00 && $_ >= 2990.00)' file

Code:
perl -nle 'print unless ($_ > 3060.00 || $_ < 2990.00)' file

Output:
Code:
3000.66
2990.00
3060.00
3002.55


Last edited by Aia; 11-05-2017 at 02:00 PM..
This User Gave Thanks to Aia For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script needed to delete to the list of files in a directory based on last created & delete them

Hi My directory structure is as below. dir1, dir2, dir3 I have the list of files to be deleted in the below path as below. /staging/retain_for_2years/Cleanup/log $ ls -lrt total 0 drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2 drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: prasadn
2 Replies

2. Shell Programming and Scripting

Delete record filter by column

Dear friend, I have a file 2 files with column wise FILE_A ------------------------------ x,1,@ y,3,$ x,5,% FILE_B -------------------- x,1,@ i like to delete the all lines in FILE_A ,if first column available in FILE_B. output (in FILE_A) y,3,$ x,5,% (10 Replies)
Discussion started by: Jewel
10 Replies

3. Shell Programming and Scripting

awk script to filter the numbers which are around the set value

Hi All, I have one sensor output(over the same) for a set value of 20. Time(in Sec), Data 1, 16 2, 20 3, 24 4, 22 5, 21 6, 20 7, 19.5 8, 20 9, 20.5 10, 20 11, 20 12, 19.5 Here we can see like after 5 sec of time the data value reaches to 20+-0.5 range. So I... (7 Replies)
Discussion started by: ks_reddy
7 Replies

4. Shell Programming and Scripting

Filter a list of IPs

Hello, I have a dump of IPs (around 2 million) and i need to filter out(delete) 37 IPs from this list. Here is a short list of IPs that i would need deleted 111.111.xxx.xxx 123.123.xxx.xxx 127.x.x.x 98.20.xx.xxx 10.135.xxx.xxx 11.105.xxx.xx 100.100.xxx.xxx 101.xxx.xx.xxx ... (11 Replies)
Discussion started by: senormarquez
11 Replies

5. Shell Programming and Scripting

awk filter numbers inbetween

Hi, I have a file which has a number in each line ( i think they are strings ) I will have a $first and $last variable, which are strings but contains only numbers. Also a file $f, I want to filter out the lines in $f with only numbers in between $first and $last. Do I need to consider the... (2 Replies)
Discussion started by: a27wang
2 Replies

6. Shell Programming and Scripting

Filter only gz files from list of subdirectories

Hi, I have a very big directory structure that consists of many sub-directories inside.There are around 50 ".gz" files under this dir structure. I want to copy all the gz files alone to a seperate location. Plz help me. (2 Replies)
Discussion started by: villain41
2 Replies

7. Shell Programming and Scripting

how to delete records with the given line numbers

I have a file which has about 10000 records and I need to delete about 50 records from the file. I know line numbers and am using sed '134,1357,......d' filename > new file. It does not seem to be working. Please Advice (5 Replies)
Discussion started by: mad_man12
5 Replies

8. Shell Programming and Scripting

delete numbers in a filename

I have some files where numbers are part of like eg 1add1.txt 23sub41.txt etc I want to remove numbers from the filenames(whereever it may be). I used echo `ls *.txt | sed -e "s///"` But its removing first digits like 1add1.txt becomes add1.txt My intention is to make 1add1.txt... (3 Replies)
Discussion started by: villain41
3 Replies

9. Shell Programming and Scripting

Urgent! Sed/Awk Filter Find Pattern Delete Till End Of Line

Hi, I need help with using an awk or sed filter on the below line ALTER TABLE "ACCOUNT" ADD CONSTRAINT "ACCOUNT_PK" PRIMARY KEY ("ACCT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "WMC_DATA" LOGGING ENABLE Look for... (2 Replies)
Discussion started by: rajan_san
2 Replies

10. AIX

Get the list, filter and delete the files on remote server

Hi, I need to login to a remote server. Go to a particular path. Get the lists of files on that path.There may be n number of files. I need to delete only those files from above created list which are 7 days older. I have achieved above using ftp protocol, but now the constraint has... (0 Replies)
Discussion started by: mail_amitnagpal
0 Replies
Login or Register to Ask a Question