7

Append: | awk '{if(NR>1){print $4-last,"("$4"-"last")"} last=$4}' Output: 26939 (265735665-265708726) 16047 (265751712-265735665) 2864 (265754576-265751712) 19804 (265774380-265754576)


4

The find command would be more appropriate: find . -name 'cats.py' -exec cat {} \;


3

You can play around with anything that can do maths (sin especially) and write a number as a character to stdout. For example: awk --characters-as-bytes 'BEGIN { freq=2200; amp=0.3; for (i=0; i>=0; i++) { printf "%c", 127+ amp*(127.0*sin(2*3.14159265/44100*i*freq)); } }' | padsp tee /dev/audio > /dev/null Depending on how you set freq it sounds more ...


3

awk '/buffer_pool_pages_flushed/{curr=$(NF-1); print curr-prev; prev=curr}'


2

Use the find command. It can find the file, and run a command on it. ls has problems, especially if the -l option is given, as then you have a lot more data than you need (file-mode, date, owner, ... ). i.e. (substitute the bits in the «») find «directory» -name '«file-name-glob-pattern»' -exec «command» {} \; e.g. find . -name 'cats.py' -exec cat {} \;


2

Assuming that you give your script the pattern like so, ./myscript '*.txt' (the quotes are necessary to avoid expanding the pattern to names in the current directory), then you may write your script like so: #!/bin/sh name_pattern=$1 find . -name "$name_pattern" This takes the first command line argument and uses it in a call to find, filtering the ...


1

Whip up a tiny C (or Perl, Python, whatever) program that reads one byte at a time and keeps totals. Any language that isn't totally braindead on a reasonable operating system will handle buffering and other chores transparently in reasonably efficient way.


1

ps -f prints the command line, ps -C is searching by the command name. These are often the same, but they don't have to be. In your setup if you tried ps -o comm,cmd 4129 you will see the two fields. The command name is the first column with the command line being the second.


1

You can achieve this kind of substitution using the \= special replace expression. Check out :help sub-replace-special for all the details, but here's how this specific replacement could work: %s/\d\+/\=str2nr(submatch(0)) > 8 ? str2nr(submatch(0)) + 2 : submatch(0) In the replacement part of the :substitute command, after the \=, submatch(0) gives you ...


1

The CPU overhead of running a single GNU Parallel job is in the order of 1-10 ms. This is partly due to being written in Perl, but mostly due to a lot of safety tests happening behind the scenes. So if you want to use GNU Parallel to run 25000 jobs per second on average, you can do: seq 1000000 | parallel -n100 --pipe --round-robin -I ,, parallel myjob {} ...


1

If you three or more as you could use: a{3,}. For example: $ echo a | grep -E 'a{3,}' $ echo aa | grep -E 'a{3,}' $ echo aaa | grep -E 'a{3,}' aaa $ echo aaaa | grep -E 'a{3,}' aaaa $ echo aaaaaaaaaa | grep -E 'a{3,}' aaaaaaaaaa If you want 3 or more as followed by something that's not a t, you could use a{3,}[^t]. For example: $ echo aaa | grep -E 'a{3,...


1

Some of these answers reference the "[random chars].default" directory. Starting with version 67, users can have profiles for different update channels (e.g., release, beta, nightly, etc.). On my Ubuntu 18 system, this directory was "[random chars].default-release". I still had a "[...].default" directory but it was mostly empty. Keep that in mind if you ...


Only top voted, non community-wiki answers of a minimum length are eligible