Basic Usage
Open a terminal.
demos/02-first.sh
demos/02-tab_and_history.sh
Commands:
pwd
- print the directory you are currently inls
- list the files and directories that are in the
current directorycd
- change directoriesdemos/03-navigation.sh
cd Desktop
ls Desktop
ls -l
ls -l -a
Commands:
mkdir
- make a new directorycp
- copy a file or directorymv
- move a file or directoryrm
- remove a file or directorydemos/04-createdelete.sh
pwd
print the “absolute path” of the current directory
(the directory you are in)./
.
/home/cclark/Desktop
./
is the current directory.../
is the parent directory (the directory above the
current directory)../Desktop
(from my home directory)../
(from my home directory)demos/04-rel_abs_paths.sh
tar
command is used to “untar” the tarball.
-x
extract archive-j
tarball has been compressed using bzip2-f
the name of the archive filetar -x -j -f Module-01-Sandbox.tar.bz2
tar
specific!)
tar -xjf Module-01-Sandbox.tar.bz2
tar xjf Module-01-Sandbox.tar.bz2
tar xfj Module-01-Sandbox.tar.bz2
demos/05-sandboxes.sh
Download the sandbox for this module and perform the following task:
data/
run03.txt
old/
, without going into the directory.old/
config/
contains a subdirectory
named resources/
. Go into this directory.
ls -l
to list the files and directories in the top
level of the sandbox from this directory.config/
(in the top level of the
sandbox) also contains a subdirectory named
physical_quantities/
, which contains a file named
constants.txt
. Delete this file without changing
directories.config/
(in the top level of the
sandbox) also contains a subdirectory named tmp/
. Delete
this directory without changing directories.The shell provides some useful features for generating argument lists.
Wildcards
*
matches anything 0 or more times
rm *.txt
will remove all files that end with
.txt
rm data-*.txt
will remove all files that begin with
data-
and end with .txt
rm */*.log
will remove all files that end with
.log
and are in a subdirectory of the current
directory.?
matches anything 0 or 1 time
rm data-0?.txt
will remove data-01.txt
,
but not data-011.txt
Expansion
file-{x,y}.txt
expands to
file-x.txt file-y.txt
mkdir dir0{1,2,3}
will create three directories named
dir01/
, dir02/
, and dir03/
.These are provided by the shell, so they will work for all commands.
demos/07-wildcards.sh
Report 1.pdf
with
rm Report 1.pdf
, the rm
command will try to
remove two files, one named Report
, and one named
1.pdf
.rm "Report 1.pdf"
rm Report\ 1.pdf
in front of
it)rm Report*1.pdf
will work
(So would rm R*.pdf
).demos/09-spaces.sh
This slides intentionally left blank