dividing file into two files using cutoff value from a column?
1
0
Entering edit mode
2.2 years ago

Hi,

I have a FILE:

BINPACKER    protein_Rf1    25.947  1.94e-31     N/A    N/A   quinoa
BINPACKER    mitochondrial  50.947  1.94e-31     N/A    N/A   quinoa

I want to divide this file based on the value in column 3 (e.g value >=50 in one file and others i.e. < 50 in other file) retaining all the columns.

Thankyou

ubuntu terminal shell linux • 475 views
ADD COMMENT
0
Entering edit mode

What have you tried? This is pretty straightforward to do in awk.

ADD REPLY
0
Entering edit mode

cat myfile.txt | awk '$3 > 50' > file_greater_than50.txt

But It is not working and also I don't how to apply =< criteria.

ADD REPLY
1
Entering edit mode

Please specify a delimiter for awk using awk -F or awk 'BEGIN { IFS=...'. >= is applied using the >= operator.

ADD REPLY
3
Entering edit mode
2.2 years ago
JC 12k

perl -lane 'print if ($F[2] >=50)' < input > output

ADD COMMENT
0
Entering edit mode

Thankyou, It worked.

ADD REPLY

Login before adding your answer.

Traffic: 2248 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6