Skip to main content

All Questions

1 vote
3 answers
420 views

Find the maximum value of Column3 and print the values of Column1 and 2 only

In Unix, I am trying to find a command that would find the maximum value in Column3 and print the corresponding values from Column2 and Column1 (but not from Column3) in a new file. Column1 ...
Michaela14's user avatar
1 vote
5 answers
5k views

Sum of even and odd numbers of odd and even lines

I would like to write a shell script program that gives the sum of even and odd numbers in a given file's odd and even lines. I would like to use: sed -n 2~2p and sed -n 1~2p but I am not even sure ...
Beszteri's user avatar
  • 113
-1 votes
1 answer
60 views

find in a file where sign of a column entry changes and print first line where this happens

I have multiply files, each with three columns. I would like to monitor where a given column entries first change sign (i.e negative to positive) so that I save that row where this first happens to ...
user343085's user avatar
9 votes
6 answers
8k views

How do I add numbers from two txt files with Bash?

I have a txt file that contains some numbers like this: 1 2 3 4 5 And I have another txt file that contains the same number of lines, but with other numbers: 6 7 8 9 10 I want ...
OhLook's user avatar
  • 217
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
3 votes
4 answers
6k views

Converting awk printf string to decimal

Task: stdout the load avg from top in a decimal form like (e.g 0.23) Details: I need to parse this script to Chef's inspec and check if its result is bigger/smaller than something, for example: ...
murloc's user avatar
  • 55
1 vote
1 answer
1k views

Compare two files for greater than value

I Have a request to alert usage of disk every 30 minutes, The thing is recent output should check old alert to avoid to send same alert again and again. #!/bin/bash #export maillist=mailxxx@gmail....
Tom's user avatar
  • 11
1 vote
1 answer
462 views

Sumation of Multiple Field Cumulative Sum

I have a | delimited file with multiple fields (Field_1 to Field_10), and some of the fields have dollar amounts. I would like to get the cumulative sum of say Field_1 ($ amount), Field_5 ($ amount),...
user4275132's user avatar
0 votes
2 answers
545 views

Shell program that outputs the averages

What I need to do is write a shell program called avgs that would read lines from the file with data, where the title line could be at any line within the data. I must keep a total and count for each ...
shawn edward's user avatar
1 vote
1 answer
540 views

validate the sequence number in the trailer of a file

We have a file that arrives daily and has a sequence number in the trailer like 9999 TR SAP _AP Distribution 0000000000000001 where 0000000000000001 is the sequence number and the file that comes ...
user86683's user avatar
  • 381
2 votes
2 answers
2k views

How to extract the positive numbers in the first column from an output as in the question?

I am running Ubuntu 14.04.1 LTS 64-bit with Bash 4.3.11(1)-release I have a program called harminv producing output as follows: $ h5totxt hsli0.126.h5 | harminv -vt 0.1 -w 2-3 -a 0.9 -f 200 # ...
Vesnog's user avatar
  • 689
3 votes
3 answers
903 views

How to find out the biggest number in many documents that contains different numbers

For example, there are some temperature data at those folders in different time. temps.txt contains the temperature number. So how can I use bash script to find out the maximum temperature? (the ...
Yunong's user avatar
  • 119
1 vote
1 answer
340 views

Summing by common strings in different files

I have a file file1 with the amount of times a user shows up in the files, something like this: 4 userC 2 userA 1 userB and I have another file file2 with users and other info like: userC, degree2 ...
GuyWhoNeedsHelp's user avatar