- Laptop
- Terminal
- Laptop
- Anaconda Powershell
- Click here to download the latest version of
Anaconda Navigator
forMacOS
- Once the download has finished run the installer
- Click here to download the latest version of
Anaconda Navigator
forWindows 10
- Once the download has finished run the installer
- Navigate to Finder > Applications > Utilities > Terminal
- Run the
Terminal
, you should see something that looks like this:
- Navigate to
Anaconda Powershell
(it should be in theStart
menu) - Run the Anaconda Powershell
Note: who would like to take a screenshot of the Anaconda Powershell and send it to me? Thx!
$
>
The command prompt, illustrated above per operating system, indicates to a user where they can enter commands (type things)
pwd
: or print working directory, shows the directory you are currently inls
: lists all contents of a directory (folder)cd
: or change directories, use this to move to a different part of your computer
-
check the current working directory (where you are on your computer):
pwd
note you should be in the
home
directory -
list the contents of the
home
directory:ls
-
choose a FOLDER to open, or change the
working directory
, withcd
:cd FOLDER
for example
cd Downloads
note the command line has autocomplete, hit TAB as you type characters to try to use it!
-
hit ENTER to run the command
-
check the command prompt, notice anything different?
my command prompt (for example)
- before step 4
(base) 95-mdpmclapca:~ cta$
- after step 4
(base) 95-mdpmclapca:Downloads cta$
- before step 4
-
confirm that the
present working directory
has changed:pwd
-
list the contents of the FOLDER directory (
Downloads
in my example):ls
-
return to the
home
directory with this SUPER FUN SHORTCUT:cd ~
-
confirm that the
present working directory
is now thehome
directory:pwd
-
note that the command prompt has returned to its default state
my command prompt (for example)
(base) 95-mdpmclapca:~ cta$
mkdir
: make and name a new directorytouch
: make and name a new fileecho
: outputs the strings being passed as arguments>
: overwrite data in a file (if the file exists)>>
: append data to a file (if the file exists)cat
: reads data from a file and outputs the datanano
: or GNU nano, a text editor
-
make a new FOLDER with
mkdir
:mkdir DATA
-
change directories into
DATA
:cd DATA
-
confirm that the
present working directory
has changed:pwd
-
make a new
.txt
file withtouch
:touch data.txt
-
confirm that
data.txt
is present inDATA
:ls
-
we can print messages at the command line with
echo
:echo "Hello World"
-
we can also use
echo
to pass information into afile
with>
:echo 'data1' > data.txt
-
confirm the contents of our file with
cat
:cat data.txt
-
let's say we have 2 data points, try adding
data2
to our file with the following:echo 'data2' > data.txt
-
confirm the contents of our file with
cat
, see any issues here?:cat data.txt
-
cat
reveals that the command in step 9 has overwrittendata1
withdata2
-
let's repeat our procedure and overwrite
data2
withdata1
:echo 'data1' > data.txt
-
here we use
>>
to appenddata2
todata.txt
:echo 'data2' >> data.txt
-
confirm the contents of our file with
cat
:cat data.txt
you should see both
data1
anddata2
-
another way to explore files via the command line is with
nano
, the command to launch teh GNU nano text editor. Opendata.txt
in nano:nano data.txt
-
you can navigate through
data.txt
with the arrow keys and will notice a rather old-fashioned User Interface at the bottom of the window. Ctl-X to exit