Oddbean new post about | logout
 If you're looking to learn to code for the joy and empowerment, I highly recommend bash script.

It helps you to be great at maintaining your computer, and following guides to install things with Linux. 

Anything you might execute from the command line is code.

Here's how you start (works on Linux or Mac)...

1) create a paranoid crypto anarchist directory and go into it

cd ~
mkdir pca
cd pca

2) make a file
touch GFY.sh

3) edit it with nano (vim later when you're getting skilled and seeking efficiency). This makes step 2 redundant, everyone relax, I know. 

nano GFY.sh

4) on line 1, very important, put...

#!/bin/bash

This turns the document into a program. 

5) Let's print something. Add these 3 lines

echo "GFY World!"
sleep 10
clear

This will print to screen, wait 10 seconds, then clear the screen, then the program ends. Notice, each new line is a new command, and they can be sequentially typed in if you want. All these lines of bash code work manually too.

6)
Make the program executable...

sudo chmod +x ~/GFY.sh

This is superuser do (elevated privileges), change mode function,   add executable option, and the path to the file (~ is shorthand to the home directory of the current user).

7) now you can run the program like this...

./GFY.sh

Or

~/GFY.sh

In the first example the full stop stands for the current directory. So whatever your directory you're in, the computer knows to replace the full stop with the current path, and then it adds on the rest. You have to be in the same directory as your program for this work.

In the second example, you don't have to be in the same directory because you're specifying the path fully, although in shorthand with ~

This might seem very trivial but it is the basic building blocks for building more and more complex things, such as Parmanode .

You can actually read the Parmanode script and see what it's doing.

Maybe I should do a video one day explaining the code.