Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#######
#
# E-scripts on basic Unix utilities.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/unix.e>
#           or at <http://angg.twu.net/e/unix.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######



# «.find»		(to "find")
# «.locate»		(to "locate")
# «.environment»	(to "environment")
# «.signals»		(to "signals")
# «.col»		(to "col")
# «.basename»		(to "basename")
# «.busybox»		(to "busybox")
# «.date»		(to "date")
# «.tar»		(to "tar")
# «.coreutils-src»	(to "coreutils-src")
# «.cli-coreutils»	(to "cli-coreutils")
# «.mv-T»		(to "mv-T")
# «.xargs»		(to "xargs")
# «.stat»		(to "stat")
# «.grep»		(to "grep")
# «.unix-works»		(to "unix-works")
# «.shebang»		(to "shebang")
# «.echo-n»		(to "echo-n")
# «.pipes»		(to "pipes")
# «.dev-full»		(to "dev-full")
# «.cut»		(to "cut")
# «.pwd»		(to "pwd")
# «.du»			(to "du")
# «.ls»			(to "ls")




#####
#
# find
# 2014jan14
#
#####

# «find» (to ".find")
# (find-node "(find)Top")
# (find-node "(find)Age Ranges" "-atime")
# (find-status   "findutils")
# (find-vldifile "findutils.list")
# (find-udfile   "findutils/")
# (find-es "bash" "redirection")
# (find-man "1 find")
# (find-man "1 find" "EXAMPLES")
# (find-man "1 find" "\nEXAMPLES\n")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-sh "find ~ -atime 0")
# (find-sh "find ~ -mmin 20")
# (find-sh "find /tmp -mmin 20")
# (find-sh "find /var -mmin -20")
# (find-sh "find /var -mmin -20 2> /dev/null")
# (find-sh "find ~    -mmin -20 2> /dev/null")

https://news.ycombinator.com/item?id=29292830 An intro to finding things in Linux (madebygps.com)




#####
#
# locate
# 2018nov14
#
#####

# «locate» (to ".locate")
# (find-sh "locate locate")
# (find-status   "locate")
# (find-vldifile "locate.list")
# (find-udfile   "locate/")
# (find-status   "findutils")
# (find-vldifile "findutils.list")
# (find-udfile   "findutils/")
# (find-node "(find)Invoking locate")




#####
#
# environment
# 2018nov14
#
#####

# «environment» (to ".environment")
# (find-node "(libc)Running a Command")
# (find-node "(libc)Program Basics")
# (find-node "(libc)Environment Variables")




#####
#
# signals
# 2019aug11
#
#####

# «signals» (to ".signals")
# https://en.wikipedia.org/wiki/Signal_(IPC)
# https://en.wikipedia.org/wiki/Signal_(IPC)#SIGINT
# (find-node "(libc)Signal Handling")
# (find-node "(libc)Termination Signals" "SIGINT")
# (find-node "(libc)Termination Signals" "SIGINT" "C-c")
# (find-node "(libc)Special Characters")
# (find-man "1 kill")
# (find-sh "kill -l")
# (find-sh "/bin/kill --list")
# (find-sh "/bin/kill -L")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
w kill
'kill' --list





#####
#
# col
# 2018nov19
#
#####

# «col» (to ".col")
# (find-status   "bsdmainutils")
# (find-vldifile "bsdmainutils.list")
# (find-udfile   "bsdmainutils/")
# (find-man "1 col")
# (find-man "1 colcrt")
# (find-man "1 calendar")
# (find-man "1 column")



#####
#
# basename
# 2018nov19
#
#####

# «basename» (to ".basename")
# (find-status   "coreutils")
# (find-vldifile "coreutils.list")
# (find-udfile   "coreutils/")
# (find-angggrep "grep --color -nH -e '$(' .zshrc")
# (find-man "1 basename")




#####
#
# What utils are in busybox?
# 2018nov19
#
#####

# «busybox» (to ".busybox")
# (find-es "busybox")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
locate bin/busybox
/bin/busybox
busybox --list




#####
#
# date
# 2018nov19
#
#####

# «date» (to ".date")
# (find-angg ".emacs" "date")
# (find-status   "coreutils")
# (find-vldifile "coreutils.list")
# (find-udfile   "coreutils/")
# (find-man "1 date")
# (find-man "1 date" "-d, --date=STRING")
# (find-man "1 date" "%j" "day of year")
# (find-node "(coreutils)Date input formats")
# (find-node "(coreutils)Pure numbers in date strings")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
date -d 20181101
date -d 2018-11-01
date -d 20181104
date -d 2018-11-04

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
ndays = {31, 28, 31, 30, 31, 30,
         31, 31, 30, 31, 30, 31}
for month=1,12 do
  for day=1,ndays[month] do
    local date = format("2018%02d%02d", month, day)
    local yday = getoutput(format("date -d %s +%%j", date))
    local yday = split(yday)[1]
    print(date, yday)
  end
end

date -d 




#####
#
# tar
# 2019apr09
#
#####

# «tar» (to ".tar")
# (find-status   "tar-doc")
# (find-vldifile "tar-doc.list")
# (find-udfile   "tar-doc/")
# (find-node "(tar)Option Summary" "--strip-components=NUMBER")
# (find-angg ".zshrc" "basename_tgz")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
FNAME=$S/https/www.haskell.org/tutorial/haskell-98-tutorial-html.tar.gz
tar -tvzf $FNAME
tar -tzf $FNAME
tar -tzf $FNAME | head -n 1
basename $(tar -tzf $FNAME | head -n 1)
basename_tgz $FNAME




#####
#
# coreutils-src
# 2020feb24
#
#####

# «coreutils-src» (to ".coreutils-src")
# (find-apt-get-source-links "coreutils")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-sh "apt-cache show    coreutils")
# (find-sh "apt-cache showsrc coreutils")
rm -Rv /tmp/d/
mkdir  /tmp/d/
cd     /tmp/d/
sudo apt-get build-dep -y   coreutils
     apt-get source         coreutils   2>&1 | tee osource
     apt-get source --build coreutils   2>&1 | tee osourceb

# (find-fline "/tmp/d/")

rm -Rv ~/usrc/coreutils-8.30/
cp -av /tmp/d/coreutils-8.30 ~/usrc/

# (code-c-d "coreutils" "~/usrc/coreutils-8.30/")
# (find-coreutilsfile "")
# (find-coreutilssh "find * | sort")
# (find-coreutilsfile "src/touch.c")
# (find-coreutilsfile "src/touch.c" "fdutimensat")
# (find-man "2 utimes")
# (find-man "2 utimensat")





#####
#
# Command line text processing with GNU Coreutils (eBook)
# 2021oct23
#
#####

# «cli-coreutils»  (to ".cli-coreutils")
# (find-books "__comp/__comp.el" "cli-coreutils")




#####
#
# mv -T
# 2020oct24
#
#####

# «mv-T»  (to ".mv-T")
# (find-man "1 mv")
# (find-man "1 mv" "-T, --no-target-directory")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-fline "/tmp/mv-test/")
rm -Rv /tmp/mv-test/
mkdir  /tmp/mv-test/
cd     /tmp/mv-test/
mkdir a/
mkdir b/
mv -ivT a b




#####
#
# xargs
# 2021jan16
#
#####

# «xargs»  (to ".xargs")
# (find-man "1 xargs")
# (find-man "1 xargs" "-I replace-str")
# (find-man "1 xargs" "-L max-lines")
# (find-man "1 xargs" "--delimiter=delim, -d delim")
# (find-man "1 xargs" "BUGS")
# (find-man "1 xargs" "BUGS" "incompatible")
# (find-node "(find)Invoking xargs")
# (find-node "(find)xargs options")
# (find-node "(find)Invoking the shell from xargs")

# (find-fline "~/LOGS/2021feb03.emacs" "echo hello ; echo world")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
(echo hello ; echo world ; echo 'how do you do' ) \
  | xargs -I '{}' -- \
      echo cp -v --parents --update '{}' ~/usrc/angg-fossil-repo/

# Bad:
(echo hello ; echo world ; echo 'how do you do' ) \
  | xargs -I '{}' -L 2 -- \
      echo cp -v --parents --update '{}' ~/usrc/angg-fossil-repo/

# Bad:
(echo hello ; echo world ; echo 'how do you do' ) \
  | xargs -L 2 -- \
    echo xargs -I '{}' -- \
      echo cp -v --parents --update '{}' ~/usrc/angg-fossil-repo/

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
seq 1 25 | xargs -I '{}' -- echo foo '{}' bar
seq 1 25 | xargs -L 5
seq 1 25 | xargs -L 5 | tr ' ' .
seq 1 25 | xargs -L 5 | tr ' ' . | xargs -d '\n'  -I '{}' -- echo foo '{}' bar
seq 1 25 | xargs -L 5            | xargs -d '\n'  -I '{}' -- echo foo '{}' bar

seq 1 25 \
  | xargs -L 5 \
  | xargs -d '\n' -I '{}' -- \
      echo cp -v --parents --update '{}' ~/usrc/angg-fossil-repo/


https://news.ycombinator.com/item?id=28258189 An Opinionated Guide to Xargs (oilshell.org)







#####
#
# stat
# 2021jan16
#
#####

# «stat»  (to ".stat")
# (find-man "1 stat")
# (find-node "(coreutils)stat invocation")
# (find-node "(coreutils)stat invocation" "The valid FORMAT directives")




#####
#
# grep and egrep
# 2021aug01
#
#####

# «grep»  (to ".grep")
# (find-man "1 grep")
# (find-man "1 grep" "egrep" "-E, --extended-regexp")
# (find-man "1 grep" "fgrep" "-F, --fixed-strings")
# (find-man "1 grep" "rgrep" "-r, --recursive")
# (find-man "1 grep" "Basic vs Extended Regular Expressions")




#####
#
# unix-works
# 2021aug04
#
#####

# «unix-works»  (to ".unix-works")

# (find-fline "~/books/kernighan_ritchie_thompson__unix_work.zip")
# (find-fline "~/usrc/DMR/")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -Rv   ~/usrc/DMR/
# mkdir  ~/usrc/DMR/
unzip -d ~/usrc/ ~/books/kernighan_ritchie_thompson__unix_work.zip
cd       ~/usrc/DMR/

# (find-man "unzip")




#####
#
# shebang
# 2021oct10
#
#####

# «shebang»  (to ".shebang")
# https://www.in-ulm.de/~mascheck/various/shebang/
# https://github.com/openbsd/src/blob/aaef17f3a84ac857498a5fb4edc99a3024829863/sys/sys/param.h#L63
# https://cgit.freebsd.org/src/tree/sys/sys/imgact.h#n41
# (find-man "1 env")
# (find-man "1 env" "-S, --split-string=S")
# (find-man "1 env" "-S/--split-string usage in scripts")




#####
#
# echo -n
# 2021oct10
#
#####

# «echo-n»  (to ".echo-n")
# (find-man "1 echo")
# (find-man "1 echo" "-n" "do not output the trailing newline")

<edrx> btw
<edrx> I used zsh for everything for ages, only used other shells
       very occasionally
<edrx> and only started using eshell for non-trivial things a few
       weeks ago - and I noticed that the default behavior of echo
       in eshell is to NOT add a newline to its output
<technomancy> edrx: yeah that's really stupid, agreed
<edrx> technomancy: I was going to ask is this behavior is allowed
       by POSIX or something like that... and I checked the manpage
       for echo here to see if there are command-line options for
       "no newline" and "yes newline"
<wasamasa> if you want portability, use printf
<edrx> and I only found this: "-n do not output the trailing
       newline"
<wasamasa> that defaults to no newline and makes formatting easy




#####
#
# pipes
# 2021oct12
#
#####

# «pipes»  (to ".pipes")
# https://ruzkuku.com/texts/unix-harmful.html
# http://www.softpanorama.org/Scripting/Piporama/history.shtml
# (find-man "1 tr")
# (find-man "1 tr" "-c, -C, --complement")
# (find-man "1 tr" "-s, --squeeze-repeats")

tr -cs A-Za-z '\n' \
  | tr A-Z a-z     \
  | sort           \
  | uniq -c        \
  | sort -rn       \
  | sed ${1}q




#####
#
# /dev/full
# 2022mar09
#
#####

# «dev-full»  (to ".dev-full")
# https://news.ycombinator.com/item?id=30611367 Bugs in Hello World (sunfishcode.online)
# https://blog.sunfishcode.online/bugs-in-hello-world/




#####
#
# cut
# 2022sep19
#
#####

# «cut»  (to ".cut")
# (find-man "1 cut")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
seq 10 20
seq 10 20 | head -n 1
seq 10 20 | head -n -1
seq 10 20 | tail -n +2

# (find-man "head")



#####
#
# pwd
# 2022sep26
#
#####

# «pwd»  (to ".pwd")
# https://lists.gnu.org/archive/html/bug-gnu-emacs/2022-09/msg02406.html

Yes, bash's built-in pwd assumes -L by default (which is what POSIX
mandates), and coreutils' pwd assumes -P by default. POSIX requires
support for both -L and -P, so the safe fix here is to replace
/bin/pwd by pwd -P.




#####
#
# du
# 2022nov24
#
#####

# «du»  (to ".du")
# (find-man "1 du")
# (find-man "1 du" "-c, --total")
# (find-man "1 du" "-h, --human-readable")
# (find-man "1 du" "-s, --summarize")




#####
#
# ls
# 2022dec06
#
#####

# «ls»  (to ".ls")
# (find-man "1 ls")
# (find-sh "ls --help")
# (find-sh "ls --help" "-S" "sort by file size")
# (find-sh "ls --help" "size (-S)")




# Alternatives to grep:
https://beyondgrep.com/feature-comparison/
https://news.ycombinator.com/item?id=16096824 abundance vs. scarcity
https://news.ycombinator.com/item?id=14693169

https://dwheeler.com/essays/fixing-unix-linux-filenames.html

https://news.ycombinator.com/item?id=30502392 Fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid (gist.github.com)
https://www.bell-labs.com/usr/dmr/www/hist.html

https://www.levenez.com/unix/
https://www.cs.dartmouth.edu/~doug/reader.pdf A Research UNIX Reader: Annotated Excerpts from the Programmer’s Manual, 1971-1986

https://news.ycombinator.com/item?id=30679923 Writing a device driver for Unix V6 (mveg.es)
https://news.ycombinator.com/item?id=31293032 Unix command line conventions over time (liw.fi) - dd is a mainframe command
https://news.ycombinator.com/item?id=31617072 The Beauty of Unix Pipelines (2020) (prithu.dev) *
https://news.ycombinator.com/item?id=31773056 pass – the standard Unix password manager (passwordstore.org)
https://news.ycombinator.com/item?id=32160339 Introduction to TCP and Sockets (2001) (scottklement.com)
https://news.ycombinator.com/item?id=32165278 Beej updated the classic Linux network programming guide (beej.us)
https://news.ycombinator.com/item?id=32314153 Xv6, a simple Unix-like teaching operating system (csail.mit.edu)
https://news.ycombinator.com/item?id=32955215 Reshaping Text (leancrew.com) - pr
https://news.ycombinator.com/item?id=32970069 Rawhide – (rh) find files using pretty C expressions (raf.org)
https://www.cs.jhu.edu/~phf/2016/fall/cs318/

https://www.gnu.org/software/parallel/20th-birthday.html
https://news.ycombinator.com/item?id=33232072 Semgrep: Writing quick rules to verify ideas (deesee.xyz)
https://news.ycombinator.com/item?id=33235315 “You meant to install ripgrep” (crates.io)
https://news.ycombinator.com/item?id=33324704 The Cult of Dd (eklitzke.org)
https://news.ycombinator.com/item?id=33583537 Building a simple shell in C – Part 3 (ehoneahobed.com)
https://news.ycombinator.com/item?id=34016518 So, what can you do with a process ID? (will-keleher.com)
https://news.ycombinator.com/item?id=34161081 The Linux Command Line (linuxcommand.org)

https://thevaluable.dev/guide-terminal-shell-console/
https://lobste.rs/s/2ghxua/guide_terminal_console_shell

<e1f> grep -A 10 for context 10 lines AFTER

https://biriukov.dev/docs/fd-pipe-session-terminal/0-sre-should-know-about-gnu-linux-shell-related-internals-file-descriptors-pipes-terminals-user-sessions-process-groups-and-daemons/
https://thenewstack.io/pipe-how-the-system-call-that-ties-unix-together-came-about/

https://news.ycombinator.com/item?id=34507230 U.S. accuses Google of abusing monopoly in ad technology (nytimes.com)
# ^
cd /tmp/
curl https://www.courtlistener.com/docket/66753787/1/united-states-v-google-llc/ \
   |sed '1,/div id=\"opinion-content\">/d;/<pre>/s//<meta charset=utf-8 \/>&/;/<\/pre>/,$d' > 1.htm
   firefox ./1.htm



#  Local Variables:
#  coding:               utf-8-unix
#  End: