Random Files We Use For Examples


We explore different commands that came with your copy of macOS or Linux operating system.

There are loads of commands.

Before we get started with showing you how some of these command work, will need files to operate on.

What we need are some large blocks of text that we can use in the examples.

The Random Files archive is full of text files for us to operate on and serve no other purpose other for demonstration. We will download the archive full of files, with the curl command.

In the examples, we are going to assume you’ve created the folder in your home directory specifically for this. If you need help, use the section  Directory Operations for help.

Alternatively, if you want to use a temporary directory, that will automatically delete itself on the next system reboot, then you can use mktemp command.

cd "$(mktemp -d)"

This will create a temporary directory and cd into it.

Each time you run it, you will end up in a different temporary directory.

Alternatively, you can use your home directory.

cd ~

Make a note of where you are running this command, as this will be where the download is stored.  If in doubt, run the pwd command.

pwd
/Users/danielplatt

Now that we are in either the temporary directory, or your home directory, we can download the collection of files using curl.

curl --location -o master.zip https://github.com/hackzilla/random-files/archive/master.zip

If all went well, you should have a file in your current directory, called master.zip

We will assume that you downloaded master.zip into your home directory.
And now we can expand the zip file, into the separate files that it contains.

unzip master.zip

You now have a directory called random-files-master, that contains a collection of text files.

Daniel

Whilst building web applications, Daniel also sets up web servers from scratch because he has yet to find the perfect hosting solution. His philosophy is “Why settle, when you can build it better yourself?”

Recent Posts