Skip to content

Tag: unix

Bash sort ignore first 5 lines

I’m having trouble ignoring the first 5 lines of my file while sorting the rest. My current command sorts the entire file by the second item, however I need to skip the first 5 “header” lines. I need read it and write it to the same file. Current Command Example Answer This sorts lines 6 and…

How to print a binary value(1010) into decimal value(10) in GDB?

I want to print the decimal value of 1010 in gdb, but it prints the result as it is what I gave last. Answer GDB’s p[rint] command prints the value of the expression you provide, which is interpreted in the source language of the program being debugged. In C, your 1010 is a decimal literal, not a binary…

How to get CPU Utilization number from top?

How would I get the number for CPU Utilization from running the top command on a specific user? Answer Pipe top to awk and add up the CPU utilization column: That awk command says “For rows (from top) greater than row 7, add up the number in field 9 $9 and store it in variable sum. Once you have gone