Skip to main content

All Questions

3 votes
3 answers
1k views

How to sort each 20 lines in a 1000 line file and save only the sorted line with highest value in each interval to another file?

I have a file that has 1000 text lines. I want to sort the 4th column at each 20 lines interval and print the output to another file. Can anybody help me with sorting them with awk or sed? Here is an ...
Sanjukta's user avatar
0 votes
2 answers
528 views

Finding values of one file within range of another file and selecting the top value

I have two files A and B. File-A has 4 columns and 600,000 rows. File-B has 4 columns and 5000 rows. Example: File-A: ENSB1 1 12245 0.53 0.002 ENSB2 1 13400 0.27 0.0003 ENSB3 1 14780 0.13 0.00001 ...
Muhammad Sajid Tahir's user avatar
3 votes
3 answers
872 views

Calculating rates / 'derivative' with awk

awk newbie here. Suppose I have two columns of data, and I want to calculate the rate of increase, given by delta(y)/delta(x). How would I do this in an awk script? What I've learnt so far only deals ...
Suraaj K S's user avatar
4 votes
2 answers
576 views

Numerical sorting of every column in a file individually using awk

I'm trying to numerically sort every column individually in a very large file. I need the command to be fast, so I'm trying to do it in an awk command. Example Input: 1,4,2,7,4 9,2,1,1,1 3,9,9,2,2 5,...
Giles's user avatar
  • 897
0 votes
4 answers
280 views

Filling empty cells and making data type the same in a tab separated file

I am dealing with a tab separated file with nearly 200MM rows on Linux. In one the columns which contains binary values, I noticed the data type is not consistent and there is a large number of ...
Alex Man's user avatar
  • 109
0 votes
5 answers
1k views

Max, Mean, Min for range within column of data

I have data structured like this :- X 43808873 A 14 X 43808874 G 7 X 43808875 T 15 X 43808876 A 13 X 43808877 T 4 X 43808878 C 13 X 43808879 T 11 X ...
kellogg76's user avatar
0 votes
1 answer
630 views

Calculating average in awk based on several column conditions in csv

I currently have the following csv format, it's much larger but I've taken a chunk of it for now. EV,"Houston","-7.0" AB,"Boston","19.0" OO,"Mystic","13.0" AB,"Boston","-12.0" EN,"New York City","9....
kayatoast's user avatar
0 votes
2 answers
43 views

Highest Columns Number Records Issue

Highest Columns Number Records Issue I have a test.txt file with contents as follows: 1:2:3 123:5 34589:5:0 34567:8:7 781:9:09 Could you please help me getting the following output from that test....
Rabindra Panigrahi's user avatar
-3 votes
1 answer
179 views

Adding a sequence of one hundred numbers to a starting number

If I have file like this: 1 19 24 119 201 230 ... then I want output like this: 1 2 3 4 .........100 19 20 21 22 .......119 24 25 26 ...........124 119 120 121 .......219 201 202 ...
daizy123's user avatar
0 votes
3 answers
1k views

multiply specific column in a file which consists of thousands columns

The in file looks like this -17.3644 0.00000000 0.00000000 .... -17.2703 0.00000000 0.00000000 .... -17.1761 0.00000000 0.00000000 .... -16.5173 0.00000000 0....
Dimitris Mintis's user avatar
0 votes
6 answers
271 views

Keep only a few digits of decimal part

I have a file whose contents look like this. 2,0,-1.8433679676403103,0.001474487996447893 3,1,0.873903837905657,0.6927701848899038 1,1,-1.700947426133768,1.5546514434152598 CSV with four columns ...
Text's user avatar
  • 3
0 votes
2 answers
606 views

When I add 0 to 0.0, how do I make sure the result is 0.0 not 0?

There are two columns of numbers in a file, the first line like this: 0 0.0 I want to add the numbers in column 1 to those in column 2, and I want to keep the results floats, not ...
XYZ's user avatar
  • 27
2 votes
1 answer
844 views

Awk - convert time value to decimal value

How can I use awk to convert a time value to a decimal value. I have been using this command for the other way round (-> from): awk '{printf "%d:%02d", ($1 * 60 / 60), ($1 * 60 % 60)}' <<< ...
nath's user avatar
  • 6,074
5 votes
3 answers
2k views

How to get sum of values in column based on variables in other column separately? [duplicate]

I have a table data like below abc 1 1 1 bcd 2 2 4 bcd 12 23 3 cde 3 5 5 cde 3 4 5 cde 14 2 25 I want the sum of values in each column based on variables in first column and ...
awkprob's user avatar
  • 53
11 votes
13 answers
3k views

How to collapse consecutive numbers into ranges?

Given a sorted input file (or command output) that contains unique numbers, one per line, I would like to collapse all runs of consecutive numbers into ranges such that n n+1 ... n+m becomes n,n+m ...
don_crissti's user avatar

15 30 50 per page