2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-15 06:12:59 +00:00
Commit Graph

13 Commits

Author SHA1 Message Date
terminalforlife
9f2dcacb25 Tweak and/or add to awk 2020-03-10 17:36:31 +00:00
terminalforlife
489af58ee9 Add nifty Awk trick to fetch the total RAM 2020-02-29 23:43:42 +00:00
terminalforlife
2ce193c0ba Fix typos, tidy formatting, & improve writing
This is what late-night boredom does to you. lol
2020-02-22 03:38:15 +00:00
terminalforlife
36b9feb0a2 Add pretty-print output taken from /etc/passwd 2019-12-05 01:01:13 +00:00
terminalforlife
09e06fc821 Add syntax for fetching lines between patterns 2019-12-01 13:00:13 +00:00
terminalforlife
0b61d3884e Fetch unique list of uppercase-only variables
Just wrote this because I'm wanting to convert numerous uppercase
variables in lots of shell programs to lowercase, except the initial
letter of a word. Manually, doing this would take forever.

First, however, I need to compile a list of variable names so I know
for what I want to search and replace, then omit certain ones typically
named in all uppercase, like `UID`, `USER`, `HOSTNAME`, etc, which I
will probably do by parsing `env` and various other special parameters
used by Bash.

Fun times.
2019-11-27 16:44:28 +00:00
terminalforlife
81711828bc Add more examples using associate array variables 2019-11-26 23:49:20 +00:00
terminalforlife
9c6e04b5c0 Add line to list unique DEB sections, using awk 2019-11-22 02:03:22 +00:00
terminalforlife
c12d8e2df2 Show counting lines awk reads from STDIN
This is useful, but not if this is _all_ you're after; in those
cases, you're better off just using `free | wc -l` or similar.

However, there may be times you need to count the number of lines in
order to achieve _other_ things programmed in awk, which would then be
crucial!

For example, you may wish to output text informing the user of how many
log entries were discovered in one or more files given to awk.
2019-11-06 00:28:10 +00:00
terminalforlife
ff4af91485 Access environment variables from within awk.
ENVIRON is a special associative array variable, and LS_COLORS is an
index therein. If you want to see the available variables you could
use, you could execute the trusty `env` command.
2019-11-06 00:18:59 +00:00
terminalforlife
fec416c763 Show using awk without data via STDIN
This is useful for those times you want to just do something in awk, -
on-the-fly, without having to rely on its standard input (STDIN).

It's especially handy when you want to perform floating-point
arithmetic, if you're not a shell like ZSH which does support it.
2019-11-06 00:11:43 +00:00
Mariusz Błaszczak
e388d3bfb5
awk: how to display only first column of text with
It might be useful e.g. when removing docker containers:
docker ps -a | grep openeir | awk '{print $1 }' | xargs docker rm
2019-03-15 11:03:07 +01:00
Igor Chubin
b11cc92cd9 added awk 2018-01-12 10:08:02 +00:00