shelllings

a practical way to learn shell
git clone https://git.davidvoz.net/shelllings.git
index
logs
tree
license

06_removing.sh
1#!/bin/sh
2
3# The previous exercises have created a mess in this folder. We can
4# clean it up using the 'rm' command.
5#
6# $ rm file # removes file
7# $ rm file1 file2 # removes files
8# $ rm -r dir/ # recursively removes files and folders
9# $ rm -rf dir/ # forces the previous command
10# $ rm * # removes all the files within the current folder,
11# saves time on not having to input every file
12# $ rmdir dir/ # removes an empty directory
13#
14# The astrisk is a very important symbol in shell programming. Take the
15# example below
16#
17# $ rm folder/*.txt
18#
19# This command will rm all the files within folder/ that end with .txt
20# meaning anyfile that ends with .c, .sh, or has no dot endings will
21# not be deleted.
22#
23# $ rm a*z
24#
25# The above command will remove any combination of files that start with
26# 'a' and end with 'z'. Including files directly named 'az' with nothing
27# inbetween.
28#
29# For your next exercise, remove the custom folder you created earlier
30# using the commands above directly in the terminal. An extra folder
31# will be created and try to remove everything in the most efficient
32# way possible when typing. Don't change anything in the code snippet
33# below
34rm -rf 06_folder
35mkdir 06_folder
36for i in $(seq 1 100); do
37 touch 06_folder/file$i
38done
39
40# in one line below, find a way to delete all the 100 files created
41# from above without deleting the folder. Test out different ways,
42# maybe combine arguments to accomplish this. Do not add more or
43# less than 44 lines of code in this file.
44