Beyond Binary Wikia

GNU is a backronym for the post-Unix operating system known as GNU.

GNU is a backronym because it's definition is self-referential: GNU stands for GNU's Not Unix.

The defining elements of GNU are that it is a freeware.

Free Software Movement

"The free software movement campaigns to win for the users of computing the freedom that comes from free software. Free software puts its users in control of their own computing. Non-free software puts its users under the power of the software's developer. See the video explanation."

"More precisely, free software means users of a program have the four essential freedoms:

  • The freedom to run the program as you wish, for any purpose (freedom 0).
  • The freedom to study how the program works, and adapt it to your needs (freedom 1). Access to the source code is a precondition for this.
  • The freedom to redistribute copies so you can help your neighbor (freedom 2).
  • The freedom to improve the program, and release your improvements to the public, so that the whole community benefits (freedom 3). Access to the source code is a precondition for this.

Developments in technology and network use have made these freedoms even more important now than they were in 1983."

GNU/Linux distributions


Has become corporate influenced, despite still being "freeware" the developers are spying on user data for profit.



"sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). While in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and is consequently more efficient. But it is sed’s ability to filter text in a pipeline which particularly distinguishes it from other types of editors."
"Normally sed is invoked like this:

For example, to replace all occurrences of ‘hello’ to ‘world’ in the file input.txt:

sed 's/hello/world/' input.txt > output.txt"
If you do not specify INPUTFILE, or if INPUTFILE is -, sed filters the contents of the standard input."

sed s (Regexp Substitution)

(substitute) Match the regular-expression against the content of the pattern space. If found, replace matched string with replacement."

| Addresses>

"GNU sed supports the following regular expression addresses. The default regular expression is Basic Regular Expression (BRE). If -E or -r options are used, The regular expression should be in Extended Regular Expression (ERE) syntax. See BRE vs ERE."
"Basic and extended regular expressions are two variations on the syntax of the specified pattern. Basic Regular Expression (BRE) syntax is the default in sed (and similarly in grep). Use the POSIX-specified -E option (-r, --regexp-extended) to enable Extended Regular Expression (ERE) syntax.
In GNU sed, the only difference between basic and extended regular expressions is in the behavior of a few special characters: ‘?’, ‘+’, parentheses, braces (‘{}’), and ‘|’.
With basic (BRE) syntax, these characters do not have special meaning unless prefixed with a backslash (‘\’); While with extended (ERE) syntax it is reversed: these characters are special unless they are prefixed with backslash (‘\’)."
"The replacement can contain \n (n being a number from 1 to 9, inclusive) references, which refer to the portion of the match which is contained between the nth \( and its matching \). Also, the replacement can contain unescaped & characters which reference the whole matched portion of the pattern space."
Finally, as a GNU sed extension, you can include a special sequence made of a backslash and one of the letters L, l, U, u, or E. The meaning is as follows:
  • \L Turn the replacement to lowercase until a \U or \E is found,
  • \l Turn the next character to lowercase,
  • \U Turn the replacement to uppercase until a \L or \E is found,
  • \u Turn the next character to uppercase,
  • \E Stop case conversion started by \L or \U.

sed y (Transliteration)

Transliterate any characters in the pattern space which match any of the source-chars with the corresponding character in dest-chars."

sed p (Printing)

"By default sed prints all processed input (except input that has been modified/deleted by commands such as d). Use -n to suppress output, and the p command to print specific lines. The following command prints only line 45 of the input file:
sed -n '45p' file.txt

sed treats multiple input files as one long stream. The following example prints the first line of the first file (one.txt) and the last line of the last file (three.txt). Use -s to reverse this behavior.

sed -n  '1p ; $p' one.txt two.txt three.txt"

sed d (Deletion) and sed q (Quit)

sed '1d'

(Removes first line)

"The following example deletes lines 30 to 35 in the input. 30,35 is an address range. d is the delete command:
sed '30,35d' input.txt > output.txt
"The following example prints all input until a line starting with the word ‘foo’ is found. If such line is found, sed will terminate with exit status 42. If such line was not found (and no other error occurred), sed will exit with status 0. /^foo/ is a regular-expression address. q is the quit command. 42 is the command option.
sed '/^foo/q42'
"[D]eleting any lines matching the regular expression /^foo/, and replacing all occurrences of the string ‘hello’ with ‘world’:
sed '/^foo/d ; s/hello/world/' input.txt > output.txt"

sed in Ruby

Try it Online!

  1. puts`sed s/[aeiou][^aeiou]//g`
  2. puts`sed /^[W\\|A\\\s]/Id`
  3. puts`sed s/\\\ //g`
  4. puts`sed s/\\\s//g`
  5. puts`sed -E s/\\\s+Wa/\\\ /g`
  6. puts`sed s\%W(.+)%/Mg`
  7. puts`dd`.gsub(/\</,"Z") \< means nothing to gsub
  8. puts`sed -E s/\\\W/Z/g`
  9. puts`sed /W/!s/./W/g` #! is negation, if // isn't matched then gsub . for W.
  10. puts`sed y/abc/zyx/` #quick transliteration
  11. puts`sed -E /1/bx;s/a/z/;:x;y/123/456/`
  12. puts`sed -n /ta\\\ W/p` #Print lines matching this

np = 1749 [= 21 [= Lp3

1749 = 53 * 11 * 3 (3-almost prime)
PID = 4426 [= 16 [= Lp7
4426 = 2213 * 2 (2-almost prime)