cat is the best text editor
Every Linux user knows they can use
cat to print out the contents of a file.
But not many know they can use
cat to directly edit a file.
Start by entering:
$ cat > lol.txt
The program will hang, waiting for you to type something.
$ cat > lol.txt
This file was created using cat (^._.^)
Hit Ctrl+D to exit!
Note that lol.txt will be completely overwritten if it already exists.
cat can be used as a text editor! Never again will you have to toil with
vim commands, sluggish IDEs, or get made fun of for using
Still not convinced? Here’s three (3) reasons why
cat is the perfect text editor!
cat binary is small. Just like a kitten.
See how its size compares to the popular text editors
$ size /usr/bin/cat /usr/bin/vim /usr/bin/nano
text data bss dec hex filename
31151 1568 408 33127 8167 /usr/bin/cat
2723805 170360 56912 2951077 2d07a5 /usr/bin/vim
304637 6002 2240 312879 4c62f /usr/bin/nano
As we can see, the
cat binary is much smaller than
Fancy GUIs like Visual Studio and Atom take forever to boot because of all the plugins and libraries bundled with them.
cat is fast! Look how quickly it prints this random header file:
$ ls -l /usr/include/netdb.h
-rw-r--r-- 1 root root 28100 Jul 6 15:16 /usr/include/netdb.h
$ time cat /usr/include/netdb.h
No need to install a fancy text editor on each new system you use.
a built in command on all UNIX distros!
How can I edit existing code without completely overwriting?
You can’t and shouldn’t need to. You’re a programmer, therefore your code always works as expected the first time :)
What about syntax highlighting?
There isn’t any! All the pretty colors will distract you from coding well.
But what if I want to write my files in reverse?
Why did you make this blog?
Because the world needs to know that
cat is the best text editor.
Is that the real reason?
Nope. I thought it was a neat, albeit unpractical way to make files.
Is cat really your text editor of choice?
No, that honor goes to vim. But I do like using cat to create small files from time to time.