From 5f9cfa558c6158af4eaf8ede320600587410867e Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Mon, 21 Jun 2021 09:33:06 -0400 Subject: [PATCH] further work --- homepage/knowledge/cat.html | 51 +++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/homepage/knowledge/cat.html b/homepage/knowledge/cat.html index 5470d6f..c513970 100644 --- a/homepage/knowledge/cat.html +++ b/homepage/knowledge/cat.html @@ -242,25 +242,44 @@ done exit 0 -

cat still has a purpose though. This shell script is relatively slow for short files and very slow for very large files (though dd itself should probably be used to copy large files from one medium to another anyway). This is provided for educational purposes (though I personally use this shell script in my system PATH; the C implementation provided compiles to a much larger binary using gcc 11.1.0, so this saves a couple kilobytes).

+

It's worth noting that the dd_ shell function in the above sample that allows for re-aliasing of dd to dd bs=1 could be replaced with a shell variable $DD with the initial value dd and a changed value according to -u of dd bs=1. However, alias dd="dd bs=1" would not work due to how shell aliases are parsed; see ShellCheck wiki page SC2262.

+ +

cat doesn't work well as a shell script though. The script is relatively slow for short files and very slow for very large files (though dd itself should probably be used to copy large files from one medium to another anyway). This is provided for educational purposes (though I personally use this shell script in my system PATH; the C implementation provided compiles to a much larger binary using gcc 11.1.0, so this saves a couple kilobytes).

Cited media and further reading