BCS215 unix
exercises
for '18/2/8
cd ~ # Your home dir
pwd
ls -l
mkdir 208
cd 208
pwd
touch a b c # Create 3 files, here
ls -l
touch .p # Create a file named ".p"
ls -l # Where is it?
ls -la # Notice . and ..
ls -a .. # View parent directory
touch apple ape abc
touch r123 r234 r345 rock
touch up
ls
cat > greetings # Use cat to enter text from stdin
Hello!
How are you?
I am fine.
Goodbye
Ctrl-D # ^D is EOF
tail -2 greetings
# Show last two lines.
echo File name "globbing" in unix
cat > globbing
* matches Anything (including empty string)
? matches Exactly one character (but not empty string)
[345] matches 3 or 4 or 5
[3-5] (ditto)
*.{jpg,jpeg,JPEG} matches any file names ending in .jpg, .jpeg, or .JPEG
(but not *.JPG)
Ctrl-D # ^D is EOF
echo Now, try some globbing.
ls a*
ls g*
ls *e
ls a*c
ls *c
ls *c*
ls r*
ls r[12]*
ls ?p*
ls [a-g]*
echo ALL DONE! Go home.
cd # Default is ~
pwd
rmdir 208 # Why is 208 still there?
mkdir sub
cd sub
touch xyz
touch .pqr
cd ..
ls sub # Where is .pqr?
la -a sub
rmdir sub # Why does this fail?
ls -a sub
rm sub/.pqr
rmdir sub
history | tail