Find entry with maximum value in one column [on hold] Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionHow can I select columns based on a control file with invalid column numbers?unix: replace one entire column in one file with a single value from another filefind and replace a string in a file without using temp file with SEDAppend a column to a csv file with value from another csv lookup tableHow to join rows with single columns to a maximum of 4 columns in one row?Using AWK to select rows with specific value in specific columnprint each Network set in separate same groupPrint random lines of file but with maximum count of a certain valueFind empty value for any name in fileHow to store output(data) in csv format?

Why is "Consequences inflicted." not a sentence?

Should I discuss the type of campaign with my players?

Why aren't air breathing engines used as small first stages

How do I stop a creek from eroding my steep embankment?

What is the longest distance a 13th-level monk can jump while attacking on the same turn?

Should I call the interviewer directly, if HR aren't responding?

When is phishing education going too far?

Antler Helmet: Can it work?

What do you call a plan that's an alternative plan in case your initial plan fails?

If Jon Snow became King of the Seven Kingdoms what would his regnal number be?

Do I really need recursive chmod to restrict access to a folder?

Can Pao de Queijo, and similar foods, be kosher for Passover?

Using et al. for a last / senior author rather than for a first author

What causes the vertical darker bands in my photo?

What is the musical term for a note that continously plays through a melody?

What happens to sewage if there is no river near by?

3 doors, three guards, one stone

How to recreate this effect in Photoshop?

When to stop saving and start investing?

If 'B is more likely given A', then 'A is more likely given B'

What LEGO pieces have "real-world" functionality?

Did Xerox really develop the first LAN?

How can players work together to take actions that are otherwise impossible?

Is the address of a local variable a constexpr?



Find entry with maximum value in one column [on hold]



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionHow can I select columns based on a control file with invalid column numbers?unix: replace one entire column in one file with a single value from another filefind and replace a string in a file without using temp file with SEDAppend a column to a csv file with value from another csv lookup tableHow to join rows with single columns to a maximum of 4 columns in one row?Using AWK to select rows with specific value in specific columnprint each Network set in separate same groupPrint random lines of file but with maximum count of a certain valueFind empty value for any name in fileHow to store output(data) in csv format?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-4















In the below example I want to only display UID and Process Name in the Access.csv file which consume the most memory. Write a shell scripts for this goal.



Access.csv looks like



UID Process Name PID MEMORY

1, A, 11, 90%
2, B, 22, 30%
3, C, 33, 115%
4, D, 44, 45%









share|improve this question









New contributor




Arad Kumari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by muru, Kusalananda Apr 12 at 14:37



  • This question does not appear to be about Unix or Linux within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.











  • 3





    Hello, and welcome to U&L! What have you tried? How did it not work as expected or intended?

    – DopeGhoti
    Apr 11 at 19:50











  • I have tried with the awk command to get the columns but i am not able to get maximum memory process.

    – Arad Kumari
    Apr 11 at 20:01






  • 1





    What are you able to get? Please show what you tried with awk.

    – jlliagre
    Apr 11 at 20:13











  • Is the empty line and the header (which does not contain any commas) part of the data?

    – Kusalananda
    Apr 12 at 5:35






  • 1





    I'm voting to close this question as off-topic because the user has not clarified the question as requested, and we aren't a script writing service.

    – Kusalananda
    Apr 12 at 14:37

















-4















In the below example I want to only display UID and Process Name in the Access.csv file which consume the most memory. Write a shell scripts for this goal.



Access.csv looks like



UID Process Name PID MEMORY

1, A, 11, 90%
2, B, 22, 30%
3, C, 33, 115%
4, D, 44, 45%









share|improve this question









New contributor




Arad Kumari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by muru, Kusalananda Apr 12 at 14:37



  • This question does not appear to be about Unix or Linux within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.











  • 3





    Hello, and welcome to U&L! What have you tried? How did it not work as expected or intended?

    – DopeGhoti
    Apr 11 at 19:50











  • I have tried with the awk command to get the columns but i am not able to get maximum memory process.

    – Arad Kumari
    Apr 11 at 20:01






  • 1





    What are you able to get? Please show what you tried with awk.

    – jlliagre
    Apr 11 at 20:13











  • Is the empty line and the header (which does not contain any commas) part of the data?

    – Kusalananda
    Apr 12 at 5:35






  • 1





    I'm voting to close this question as off-topic because the user has not clarified the question as requested, and we aren't a script writing service.

    – Kusalananda
    Apr 12 at 14:37













-4












-4








-4








In the below example I want to only display UID and Process Name in the Access.csv file which consume the most memory. Write a shell scripts for this goal.



Access.csv looks like



UID Process Name PID MEMORY

1, A, 11, 90%
2, B, 22, 30%
3, C, 33, 115%
4, D, 44, 45%









share|improve this question









New contributor




Arad Kumari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












In the below example I want to only display UID and Process Name in the Access.csv file which consume the most memory. Write a shell scripts for this goal.



Access.csv looks like



UID Process Name PID MEMORY

1, A, 11, 90%
2, B, 22, 30%
3, C, 33, 115%
4, D, 44, 45%






text-processing csv






share|improve this question









New contributor




Arad Kumari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Arad Kumari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Apr 12 at 5:33









Kusalananda

142k18265440




142k18265440






New contributor




Arad Kumari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 11 at 19:28









Arad KumariArad Kumari

1




1




New contributor




Arad Kumari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Arad Kumari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Arad Kumari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by muru, Kusalananda Apr 12 at 14:37



  • This question does not appear to be about Unix or Linux within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.







put on hold as off-topic by muru, Kusalananda Apr 12 at 14:37



  • This question does not appear to be about Unix or Linux within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.







  • 3





    Hello, and welcome to U&L! What have you tried? How did it not work as expected or intended?

    – DopeGhoti
    Apr 11 at 19:50











  • I have tried with the awk command to get the columns but i am not able to get maximum memory process.

    – Arad Kumari
    Apr 11 at 20:01






  • 1





    What are you able to get? Please show what you tried with awk.

    – jlliagre
    Apr 11 at 20:13











  • Is the empty line and the header (which does not contain any commas) part of the data?

    – Kusalananda
    Apr 12 at 5:35






  • 1





    I'm voting to close this question as off-topic because the user has not clarified the question as requested, and we aren't a script writing service.

    – Kusalananda
    Apr 12 at 14:37












  • 3





    Hello, and welcome to U&L! What have you tried? How did it not work as expected or intended?

    – DopeGhoti
    Apr 11 at 19:50











  • I have tried with the awk command to get the columns but i am not able to get maximum memory process.

    – Arad Kumari
    Apr 11 at 20:01






  • 1





    What are you able to get? Please show what you tried with awk.

    – jlliagre
    Apr 11 at 20:13











  • Is the empty line and the header (which does not contain any commas) part of the data?

    – Kusalananda
    Apr 12 at 5:35






  • 1





    I'm voting to close this question as off-topic because the user has not clarified the question as requested, and we aren't a script writing service.

    – Kusalananda
    Apr 12 at 14:37







3




3





Hello, and welcome to U&L! What have you tried? How did it not work as expected or intended?

– DopeGhoti
Apr 11 at 19:50





Hello, and welcome to U&L! What have you tried? How did it not work as expected or intended?

– DopeGhoti
Apr 11 at 19:50













I have tried with the awk command to get the columns but i am not able to get maximum memory process.

– Arad Kumari
Apr 11 at 20:01





I have tried with the awk command to get the columns but i am not able to get maximum memory process.

– Arad Kumari
Apr 11 at 20:01




1




1





What are you able to get? Please show what you tried with awk.

– jlliagre
Apr 11 at 20:13





What are you able to get? Please show what you tried with awk.

– jlliagre
Apr 11 at 20:13













Is the empty line and the header (which does not contain any commas) part of the data?

– Kusalananda
Apr 12 at 5:35





Is the empty line and the header (which does not contain any commas) part of the data?

– Kusalananda
Apr 12 at 5:35




1




1





I'm voting to close this question as off-topic because the user has not clarified the question as requested, and we aren't a script writing service.

– Kusalananda
Apr 12 at 14:37





I'm voting to close this question as off-topic because the user has not clarified the question as requested, and we aren't a script writing service.

– Kusalananda
Apr 12 at 14:37










3 Answers
3






active

oldest

votes


















0














Try this:



awk '^UID/) print $4,$1,$2' Access.csv | sort | awk ' if (NR == 1) print substr($3,0,(length($3))-1),substr($2,0,(length($2))-1)'



There's probably a way to do this with just one awk command (and no sort command), but I'm still learning awk, and don't really know how to make it print JUST the line that has the largest value in field four, hence my decision to pipe it to sort and have a second awk instance deal with it.



In any case, this should work. If you need to display column headers ("UID, Process"), here's an alternate version:



awk '^UID/) print $4,$1,$2' Access.csv | sort | awk ' if (NR == 1) print "UIDtProcess Namen" substr($3,0,(length($3))-1) "t" substr($2,0,(length($2))-1)'






share|improve this answer
































    0














    You can use



     sort -nrk4 file | awk -F',' 'BEGINprint("IDtNAMEn") NR== 1 print($1,$2)'





    share|improve this answer






























      0














      You could do this from a bash command line as shown:



      Command-line:



      $ perl -F, -lane '
      print,next if $. == 1;
      $F[-1] > $max and ($L,$max) = ($_,$F[-1]);
      } sort print $L;
      ' input.csv


      Results:



      UID,Process Name,PID,MEMORY
      3,C,33,115%





      shareprint $L;
      ' input.csv


      Results:



      UID,Process Name,PID,MEMORY
      3,C,33,115%





      shareprint $L;
      ' input.csv


      Results:



      UID,Process Name,PID,MEMORY
      3,C,33,115%





      share{print $L;
      ' input.csv


      Results:



      UID,Process Name,PID,MEMORY
      3,C,33,115%






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Apr 12 at 6:34









      Rakesh SharmaRakesh Sharma

      262




      262













          Popular posts from this blog

          getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

          Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

          NetworkManager fails with “Could not find source connection”Trouble connecting to VPN using network-manager, while command line worksHow can I be notified about state changes to a VPN adapterBacktrack 5 R3 - Refuses to connect to VPNFeed all traffic through OpenVPN for a specific network namespace onlyRun daemon on startup in Debian once openvpn connection establishedpfsense tcp connection between openvpn and lan is brokenInternet connection problem with web browsers onlyWhy does NetworkManager explicitly support tun/tap devices?Browser issues with VPNTwo IP addresses assigned to the same network card - OpenVPN issues?Cannot connect to WiFi with nmcli, although secrets are provided