Skip to content

Instantly share code, notes, and snippets.

@pkbanks
Last active February 20, 2018 22:15
Show Gist options
  • Save pkbanks/c3a6a420891abbda8c5d419c6d06cdce to your computer and use it in GitHub Desktop.
Save pkbanks/c3a6a420891abbda8c5d419c6d06cdce to your computer and use it in GitHub Desktop.
answer key to CLI Hackathon (without BONUS)

Command Line Hackathon

List all the files in the directory, even the hidden ones using ls and some flags

  $ ls -a

Output the contents of the .hidden file using the cat command

  $ cat .hidden

Create a file called hello.txt

  $ touch hello.txt

Add a line that says im learning command line to the end of the hello.txt file you just created.

  $ echo im learning command line > hello.txt

Create a folder called downloaded

  $ mkdir downloaded

Download this text file from the terminal and send it's output to a file in the downloaded folder called other-info.txt. Verify that it worked by using ls.

  $ curl https://gist.githubusercontent.com/abunsen/076a420b5d2c86066f4fbf4757cefcc3/raw/5cdd592cccbfb9d5fab8f7a0764ef3dadc574831/somefile.txt > downloaded/other-info.txt

cat the file at downloaded/other-info.txt and pipe its output to grep and search for lines that say getting better You should see 2 lines outputted.

  $ cat downloaded/other-info.txt | grep "getting better"

Create a file called other-stuff.csv in the downloaded folder without cding into it.

  $ touch downloaded/other-stuff.csv

Create a file called not-other.txt in the downloaded folder without cding into it.

  $ touch downloaded/not-other.txt

List all of the files in the downloaded that start with other without changing directories?

  $ ls downloaded/other*

Run the ruby file with the really long file name that we included in this directory. We are not naming the file because we do not want you to copy the file name. Find a shortcut to autocomplete the file name.

  $ ruby run<tab>

Stop running the ruby file you just started, it's stuck.

  <control>+c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment