Shell Scripting

Shell Scripting

L1. Introduction to Shell

C1: manipulating files and directories

pwd: where am I?

Shell Scripting

ls: how can I identify files and directories?

Shell Scripting

How else can I identify files and directories?

Shell Scripting

cd: how can I move to another directory?

Shell Scripting

How can I move up a directory?

Shell Scripting

cp: how can I copy files?

Shell Scripting

mv: how can I move a file?

Shell Scripting

mv: how can I rename files?

Shell Scripting

rm: how can I delete files?

Shell Scripting

rmdir: how can I create and delete directories?

Shell Scripting

C2: manipulating data

cat: how can I view a file’s contents?

Shell Scripting

less: how can I view a file’s contents piece by piece?

Shell Scripting

head: how can I look at the start of a file?

Shell Scripting

tab completion: how can I type less?

Shell Scripting

command-line flag: how can I control what commands do?

Shell Scripting

-R: how can I list everything below a directory?

Shell Scripting
To help you know what is what, ls has another flag -F that prints a / after the name of every directory and a * after the name of every runnable program.

man: how can I get help for a command?

Shell Scripting
Shell Scripting

cut: how can I select columns from a file?

Shell Scripting

What can’t cut do?

Shell Scripting

history: how can I repeat commands?

Shell Scripting

grep: how can I select lines containing specific values?

Shell Scripting

paste: why isn’t it always safe to treat data as text?

Shell Scripting

C3: combining tools

>: how can I store a command’s output in a file?

Shell Scripting

How can I use a command’s output as an input?

Shell Scripting

What’s a better way to combine commands?

Shell Scripting

How can I combine many commands?

Shell Scripting

wc: How can I count the records in a file?

Shell Scripting

*: how can I specify many files at once?

Shell Scripting

What other wildcards can I use?

Shell Scripting

sort: how can I sort lines of text?

Shell Scripting

uniq: how can I remove duplicate lines?

Shell Scripting

How can I save the output of a pipe?

Shell Scripting

Ctrl+C: how can I stop a running program?

Shell Scripting

C4: batch processing

How does the shell store information?

Shell Scripting
Answer: 2000

echo: how can I print a variable’s value?

Shell Scripting

shell variable: how else does the shell store information?

Shell Scripting

loop: how can I repeat a command many times?

Shell Scripting

How can I repeat a command once for each file?

Shell Scripting

How can I record the names of a set of files?

Shell Scripting

A variable’s name versus its value

Shell Scripting

How can I run many commands in a single loop?

Shell Scripting

Why shouldn’t I use spaces in filenames?

Shell Scripting

How can I do many things in a single loop?

Shell Scripting

C5: creating new tools

nano: how can I edit a file?

Shell Scripting

history: how can I record what I just did?

Shell Scripting

How can I save commands to re-run later?

Shell Scripting

bash script: how can I re-use pipes?

Shell Scripting

[email protected]: how can I pass filenames to scripts?

Shell Scripting

$1, $2, … : how can I process a single argument?

Shell Scripting

How can one shell script do many things?

Shell Scripting

How can I write loops in a shell script?

Shell Scripting

What happens when I don’t provide filenames?

Shell Scripting