So, week one of the pre-course is complete. I’ve attended my first coding meet up with the team, solved a murder mystery using the command line and pushed code to GitHub for the very first time. Baby steps.
Let’s go through some of what I’ve learnt so far!
Also known as the terminal for Mac, the command line allows you to interact directly with your computer and perform useful tasks (or ‘commands’) for file management.
But just look at it – kinda scary huh? All the empty white space and that flashing cursor mocking you: “Go on. I dare you to make the first move”. It isn’t the most inviting interface, and when you’re struggling to simply locate a file up two directories and down another it is ever so tempting to grab that trusty mouse and head on over to the friendly, smiling Finder icon.
But no! Who needs a flashy GUI when you can fumble in the darkness? Oh no, not I.
Casting our mice aside, we all managed to master the basics of command line navigation and manipulation (copying, moving, creating and deleting) and were introduced to some more powerful tools like pipe, redirection and grep. Through completing our first weekly challenge – solving a murder mystery by dissecting various files for clues – it really started to sink in how powerful the command line could really be. It may not be as intuitive as a GUI, but the sheer scalability command line brings to tasks will be invaluable in the coming months I’m sure.
For those who are interested, someone in my team (thanks Jonathan!) found this handy cheatsheet on GitHub listing a whole load of useful commands and shortcuts. Mighty handy.
As a quick example of some nifty functionality, take a look at the following command:
- First, we concatenate (ie squidge together) two files imaginatively named file1 and file2. This is how I’ve named all my files all my life – my CV is handily named file5903 and a list of ‘Year 4 boyz I fink R cute’ is file3.
- We then use pipe (|) to read the output of this command and pass it as the input of the next command – like a relay!
- grep (short for global regular expression print) then filters for lines containing the expression ‘kittens’.
- A second pipe is then used to pass our output to the ‘wc’ (word count) command with the -l flag. A flag (or switch) specifies an option for a certain command, and in this case the -l modifies the wc command to return a line count only.
In short, we’ve just counted how many lines in file1 and file2 contain the word ‘kittens’. Clever.
Anyway, in conclusion, yes – when you first start out, the command line may look intimidating but it really is a friendly (and powerful!) beast that I’m sure I’ll learn to love.