-
Notifications
You must be signed in to change notification settings - Fork 0
/
random.txt
35 lines (26 loc) · 1.43 KB
/
random.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
This is not about a command "random" but literally for random shit.
Some of it should move to regular notes one day.
# Copy file from server A to server C via localhost (or another server)
$ ssh server_A 'cat sourcefile' | ssh server_B 'cat > targetfile'
# with PROGRESS
$ ssh server_A 'cat sourcefile' | \e[32;1mpv [-s $filesize] [-i sec] |\e[0m ssh server_B 'cat > targetfile'
# optional filesize is in bytes of course, interval -i in seconds, which can be decimal 0.1
# you can add \e[38;5;208mtar\e[0m and \e[38;5;208mgunzip\e[0m and \e[38;5;208mgzip -c\e[0m to the quoted commands too.
# get directory sizes for multiple directories AND the grand total:
du -sh\e[38;5;205mc\e[0m dir1 dir2 dir3
# get size per directory in given path and the total from all files directly in path:
du -hd 1
# to reverse input use \e[38;5;208mtac\e[0m, not sort
tac somefile.txt
bash completion functions aren't even DEFINED before trying to tab-complete a command, so if you want to see the
function slam tab a couple times on it first.
# pretty-print XML
xmllint --format <file> \e[36m# and pipe through \e[38;5;208mless\e[36m, probably
# change the last modified date on a file with touch -t [YY]YYMMDDhhmm[.ss]
touch -t 202308121520.12 somefile.txt
# date from a specific timestamp, -d or --date:
$ date -d @1703028415
Wed Dec 20 00:26:55 CET 2023
# with '+<format>' you can probably wrangle that to something useful, even
# random line from file
shuf -n1 <file>