From the course: Linux: Bash Shell and Scripts
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Challenges: Looping, special variable operators, sed, and AWK - Linux Tutorial
From the course: Linux: Bash Shell and Scripts
Challenges: Looping, special variable operators, sed, and AWK
(cymbal sound) - [Instructor] Let's try some challenges. First of all, let's write a script that loops through all the command line arguments, echoing them one per line. Then write a script that we'll assign to the variable file so we get a variable called file that you're gonna assign to the value of the variable TheFile if TheFile is set. Otherwise, file should get the value /tmp/data.file. So the default to assign the file is tmp/data.file if TheFile is not set. And use a special Unset/Null expansion operator. The $ brace technique that we talked about. Finally, write a script that's gonna show you the names of the c files without the .c in the current directory, and use a special string suffix operation. Now we've got a challenge for you to write a script that uses sed, a sed script should not echo out line 1, and for each line it should remove the first space through the end of the line, so we just see everything up to the first space, you should test it with ls-s piped into bash…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Defining filters and using head, tail, and wc5m 3s
-
(Locked)
Using sed and AWK for more powerful scripting13m 22s
-
(Locked)
Positional parameters and operators with braces10m 7s
-
(Locked)
Challenges: Looping, special variable operators, sed, and AWK1m 54s
-
(Locked)
Solutions: Looping, special variable operators, sed, and AWK2m 25s
-
(Locked)
-
-