New answers tagged

0

Here's a bash-only option, no bc or any other non-builtins, + decimal format and binary units. bytesToHuman() { b=${1:-0}; d=''; s=0; S=(Bytes {K,M,G,T,E,P,Y,Z}iB) while ((b > 1024)); do d="$(printf ".%02d" $((b % 1024 * 100 / 1024)))" b=$((b / 1024)) let s++ done echo "$b$d ${S[$s]}" } Examples: $ bytesToHuman ...


1

I filter the output with awk, using the fact the pid 2 is the parent of all kernel threads: ps -fHuroot | awk '$3!=2' This prints only lines where the third field (PPID) is not 2.


3

ps output can be filtered in may ways. To see your processes, you could filter by the user/uid. relevant man page below -- U userlist Select by effective user ID (EUID) or name. This selects the processes whose effective user name or ID is in userlist. The effective user ID describes the user whose file access ...


7

[ is same command as test. On some *nix systems, one is just a link to the other. For example, if you run: strings /usr/bin/test strings /usr/bin/[ you will see the same output. Most sh-shells/posix-shells include builtin [ and test commands. The same is true for echo. There is both a /bin/echo command and a builtin in most of shells. That it's the ...


23

In most cases, [ is a shell builtin and is equivalent to test. However, like test, it also exists as a standalone executable: that's the /bin/[ you saw. You can test this with type -a [ (on an Arch Linux system, running bash): $ type -a [ [ is a shell builtin [ is /bin/[ So, on my system, I have two [: my shell's builtin and the executable in /bin. The ...


10

That is used for condition testing in shell scripts. Another name of this program is test: if [ 1 -lt 2 ]; then ... That looks like shell grammar but isn't. Usually [ is a shell builtin but probably as fallback it exists as an external command. See the block "CONDITIONAL EXPRESSIONS" in man bash.


2

The simplest and less intrusive way to get a large number of utilities would be to find a busybox binary suitable for your OS and install it. That is a single file but it provides several hundreds of commands.


3

No If they are not there and you don`t have package management tools and not even a compiler (and presumably appropriate header files) your only choice is to install statically build binaries. There are numerous disadvantages to this approach, e.g. increased file size, having to replace all binaries even if just a library requires an update (such as a ...


0

I ended up using the following script to launch the program and replaced it with the default pointer to the application. #!/bin/bash echo -n "$(date +%s)" >> ~/myapplog.log /application_path/ echo ",$(date +%s)" >> ~/myapplog.log It basically logs the start and stop times of the application in form of timestamp for each session in a new line ...


6

The accounting utilities (e.g. GNU's implementation) track user activity and provide a number of tools to report on it; for example, lastcomm will list the last commands executed, and sa (run as root) will provide an activity summary. To show the amount of time a given process ran, do something like sudo sa | grep chromium This will output a number ...



Top 50 recent answers are included