What follows is my personal opinion; votes will show whether others agree or not. I like to be outspoken and clear which is sometimes misunderstood as being rude and hostile. Please bear with me; in no way do I intend to offend anybody.
Your question is unclear and thus unlikely to help others. Only with the help of the answer am I able to guess what you’re asking for. Here’s what I think you’re actually asking:
I have a text file with multiple lines whose first
(whitespace-separated) column contains an integer. I want to remove
every line with
- the most occuring integer in this column and
- any integer greater than this most occuring one.
How can I do that?
Example input
1 /mnt/e/bin/ps-suspects.sh Possible suspects causing problems
11 1 S root 128 2 0 60 -20 - 0 - 03:27 ?
11 4 Z root 19087 7064 0 80 0 - 0 - 03:32 ?
11 1 S root 75 2 0 60 -20 - 0 - 03:27 ?
3 1 S root 469 2 0 60 -20 - 0 - 03:27 ?
3 1 S root 468 2 0 60 -20 - 0 - 03:27 ?
22 0 S rick 17058 2859 0 80 0 - 7413 wait 16:56 pts/2
Here, 11
occurs most often and 22
is greater than 11
, so every
line containing 11
or 22
in the first column needs to be removed.
Example output
1 /mnt/e/bin/ps-suspects.sh Possible suspects causing problems
3 1 S root 469 2 0 60 -20 - 0 - 03:27 ?
3 1 S root 468 2 0 60 -20 - 0 - 03:27 ?
This should be the question and seems to be the only part that’s relevant and possibly helpful to others. If you really feel like this could be an XY problem (and only then) you can include further information on why you need this, but:
- keep it clearly separated from the actual question (= “tl;dr” section), connected by footnote marks at most
- from the beginning, explain clearly where you’re coming from, what you want to achieve in the end and where you’re stuck
- (you certainly know what you’re doing, so) cut code and terminal output to only include relevant and non-redundant information
The echo
lines from your script are nothing but noise in the context of your question, and the post contains them twice.
Not nearly as important as what’s said above, but still worth mentioning: Add tags according to their description, not because the tag name happens to be mentioned in your post. Your question is about text-processing rather than sort or uniq.
bash
, process ID (PID),sed
,sort
,grep
,awk
anduniq
questions here all the time. So unless it's the issue of discovering what programs are running when, I don't think it's off-topic based on programming. For that it would be specific questions aboutC
code or something similar I think.