Giter Site home page Giter Site logo

kwk-l1-find-missing-pet-kwk-students-l1-tul-070918's Introduction

Find the Missing Pet

Instructions

Missing pet

You just began your job as Web Developer at the Animal Sanctuary, and they aren't very good at organizing the photos of their favorite alumni animals. Somehow all photos ended up in the wrong folders! It's your job to move through their directory structure and put the animals in their right place. The photos have been named really well, so figuring out their correct location shouldn't be too tricky.

Because you're a legit programmer, you know the most efficient way is to navigate the directories in the command line. Use your bash command line skills to move the photos into their correct folders!

As a refresher, here's a list of commands to help you with this task:

pwd print working directory - shows you where you are

cd .. change your current directory to the parent (one above it)

ls list all files and directories

mv move a file. The mv command needs two extra pieces of information, the name of the file you're moving and where you want to move it. Let's say I want to move a file named me.txt back a level, I would enter mv me.txt ...

Remember, it's always helpful to know where you are in your directory tree in relation to where you want to go. Keep that in mind as you write out your command-line paths!

Get working!

Click the "Open" button to start this lab. In your IDE terminal, run bundle to make sure the lab is setup.

Run learn in the terminal to check your progress! spec/pet_spec.rb contains code that will check your placement of the animals to see if they are in the right place or not. This file will also print the result to the terminal screen, so you can keep track of which animals you've brought home.

Use the commands we've learned to move the animals to their right places. When everything prints green, you've successfully organized all the Animal Sanctuary's adorable animal pics!

Let's Move One File Together

Notice that the painting-elephants.jpg image is located in (lab root) > cats > indoor > back-alley. But really, the painting elephant should go inside of (lab root) > elephants > painters.

We can move this elephant image by entering in terminal from the main directory of this project...

cd cats
cd indoor
cd back-alley
mv painting-elephants.jpg ..
cd ..
mv painting-elephants.jpg ..
cd ..
mv painting-elephants.jpg ..
cd ..
mv painting-elephants.jpg elephants
cd elephants
mv painting-elephants.jpg painters

BUT WOW that's a lot of steps. Programming is all about making things simple, so there has to be a better way. In fact, we can actually combine all the steps into one short line:

mv cats/indoor/back-alley/painting-elephants.jpg elephants/painters

For this, we're using relative paths. We're inside of the "lab root" directory, and we're not going to use cd to move ourselves anywhere.Because painting-elephants.jpg doesn't exist inside the "lab root" directory, we have to tell the computer follow path to go to find that image, which is through the cats directory, and then indoor and then finally back-alley.

Next, we have to tell the computer where to move the image. Because we're inside lab root and so is the elephants directory, we can just go straight there, and then into painters.

KWK-L1 Find the Missing Pet

kwk-l1-find-missing-pet-kwk-students-l1-tul-070918's People

Contributors

danielseehausen avatar sgharms avatar aviflombaum avatar sammarcus avatar dfenjves avatar

Watchers

 avatar Rishikesh Tirumala avatar James Cloos avatar  avatar Victoria Thevenot avatar  avatar Joe Cardarelli avatar Sam Birk avatar Sara Tibbetts avatar The Learn Team avatar Sophie DeBenedetto avatar  avatar Antoin avatar Alex Griffith avatar  avatar Amanda D'Avria avatar  avatar Nicole Kroese  avatar Lisa Jiang avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.