Command line crash course exercise 7 mac

Here is my code from my terminal:
MacBook-Air:temp aka2d7$ cd stuff/things/orange/apple/pear/grape/
MacBook-Air:grape aka2d7$ cd …
MacBook-Air:pear aka2d7$ rmdir grape
MacBook-Air:pear aka2d7$ cd …
MacBook-Air:apple aka2d7$ rmdir pear
rmdir: pear: Directory not empty
MacBook-Air:apple aka2d7$ cd …
MacBook-Air:orange aka2d7$ grape
-bash: grape: command not found
MacBook-Air:orange aka2d7$ pear
-bash: pear: command not found
MacBook-Air:orange aka2d7$ cd …
MacBook-Air:things aka2d7$ ls
orange
MacBook-Air:things aka2d7$ rmdir orange
rmdir: orange: Directory not empty
MacBook-Air:things aka2d7$ cd …
MacBook-Air:stuff aka2d7$ rmdir apple
rmdir: apple: No such file or directory
MacBook-Air:stuff aka2d7$ cd …

I’m using MacOS and when I look on my hard drive I see a folder called Temp and in that folder are the following folders
Temp
Stuff
things
orange
apple
pear
when I try to remove directory it says no such file or directory, or command not found, or directory not empty. Can some please help me? Thanks in advance for you help.

Hello @lcarlos1.

Use the command: ”pwd” to see where you are.
Then use command:”ls” to see which files and folders you have in there.

If a folder you want to delete is not empty there is two ways to go.
You can cd into that folder and empty this folder from there.
Or you can use command: rm -r (the name of the folder)
Use ”man rm” for details.

But be sure you know whats inside!
There is no trash you can go into and get the file/folder back again.

1 Like

I will try this and let you know if this worked. Thanks in advance for your help!

Hi ulfen69,

I’m still not able to remove those folders. Please see the code below its saying no such file or directory. Can you please assist me with removing these folders?
Last login: Sun Jul 8 11:13:40 on ttys001
MacBook-Air:~ aka2d7$ pwd
/Users/aka2d7
MacBook-Air:~ aka2d7$ cd temp
MacBook-Air:temp aka2d7$ ls
stuff
MacBook-Air:temp aka2d7$ cd stuff/things/orange/apple/pear/
MacBook-Air:pear aka2d7$ rm -r pear
rm: pear: No such file or directory
MacBook-Air:pear aka2d7$ rm -rpear
rm: illegal option – p
usage: rm [-f | -i] [-dPRrvW] file …
unlink file
MacBook-Air:pear aka2d7$ rm -fpear
rm: illegal option – p
usage: rm [-f | -i] [-dPRrvW] file …
unlink file
MacBook-Air:pear aka2d7$

Thanks in advance for your help!
aka2d7

Hello again @lcarlos1.

I can see you started to see where you are.

pwd

Then you moved into temp.

cd temp

Checked whats inside.

ls

Then moved all the way into pear/

cd stuff/things/orange/apple/pear/

So far so good.

But then you tried to remove the directory are in at that moment (pear/)

rm -r pear

You have to step up one directory. This you do with "

cd ..

If you do “ls” from directory apple/ you should now see pear/. Now it is possible to remove it

After this you accidentally put the flag “-f” together with pear. Then you got the “error message”

rm -rpear
rm: illegal option – p
usage: rm [-f | -i] [-dPRrvW] file …
unlink file.

Hello ulfen69,

I’m sorry but I’m not understanding what I’m doing wrong, please help.
MacBook-Air:temp aka2d7$ cd stuff/things/orange/apple/pear/
MacBook-Air:pear aka2d7$ cd …
MacBook-Air:apple aka2d7$ ls
pear
MacBook-Air:apple aka2d7$ rmdir pear
rmdir: pear: Directory not empty
MacBook-Air:apple aka2d7$ rmdir pear
rmdir: pear: Directory not empty
MacBook-Air:apple aka2d7$ rmdir pear
rmdir: pear: Directory not empty
MacBook-Air:apple aka2d7$

Thanks,
aka2d7

Hi.
I have linux and you have a mac I can see.
But the commands should be the same for them beacuse they are unix based.

Try:

rm -r pear

if you are in “apple”

ulfen69,

Thanks! I really appreciate your help as I begin learning this tool/application. I’m excited to get started. I also need help with the first exercise because I’m not able to open the file in the terminal and I’m not sure I’m not doing to make this work.

MacBook-Air:~ aka2d7$ cd lpthw
MacBook-Air:lpthw aka2d7$ python3.6 ex1.py
/Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python: can’t open file ‘ex1.py’: [Errno 2] No such file or directory
MacBook-Air:lpthw aka2d7$ python ex1.py
python: can’t open file ‘ex1.py’: [Errno 2] No such file or directory

Thanks,
aka2d7

Hi @lcarlos1.

Do you have this file (ex1.py) in this directory?
Or did you save it elsewhere?

Perhaps the command:

find -name ex1.py

helps to find where it can be.

Otherwise create a new one. In directory lpthw/
You have to be in the directory if you use command:

python3 ex1.py

There is also a way to start it from “some distance”

python3 home/ulfen69/lpthw/ex1.py 

In my case.

this is where it is located:
/Users/aka2d7/Documents/Linda/lpthw/ex1.py but I’m not sure how to access it.
I copied this path directly from the Atom.

Thanks,
Linda

Hi ulfen69,

It was a user error I left the (s) off of documents… I good for now… thanks!

A tip on this one.
Use the tab key to get the file/directory faster.
You just have to start typing the first letters in the name. When you then press tab you get help with the rest.
If there are many files starting equally it stops where at the end of the equal part waiting for next letter. If you then type next letter and press tab again it completete the name for you.

Thanks a ton @ulfen69 for all your help with people. This description of what to do is excellent.

1 Like

@zedshaw

My pleasure.
I am very glad if I can help others with my knowledge. I also think it is a way to ”pay back”. So many others have helped me
Beside of this I think also learn more when helping. I have to think twice (at least) before answer a question.

Feeling proud when you say my explantion was excellent. :slightly_smiling_face:

It’s also a good way to learn more. You learn a lot by attempting to teach what you learn to someone else. The act of having to explain something forces you to figure it out explicitly rather than just kind of implicitly.

  1. it is not cd … it is cd … – to go back to previous directory.
  2. you can remove - cd stuff/things/orange/apple/ ; rm -rf pear
1 Like

it is 2 dots not 3 but when you pist the message it is putting 3 dots.

1 Like