From the course: Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Challenge: Looping and special variable operators - Linux Tutorial
From the course: Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation
Challenge: Looping and special variable operators
(upbeat music) - [Instructor] All right. This chapter had so much good stuff. We're going to have two sets of challenges. Let's look at the first set right now. First one is "Write a script that loops through all the command-line arguments, echoing them one per line." That'll give you some practice with command line arguments. Second one, "Write a script that will assign to the variable File the value of the variable, TheFile if TheFile is set; otherwise, it'll assign to file the value "/tmp/data.file". That can use those special operators we just looked at, right, so it's the unset null operations you want to check out. And then for the third one, "Write a script that will echo all the names of the .c files in the current directory, but don't include the .c suffix." So strip off that .c, right? So for prog.c, you would just be echoing out prog and use the string operations that we just talked about, right? Some good challenges there. I'll show you the solutions right after this.
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
-
-
-
-
-
Defining filters and using head, tail, and wc3m 18s
-
(Locked)
The use of sed for powerful scripting5m 55s
-
(Locked)
Using AWK5m 22s
-
(Locked)
Positional parameters and curly braces for variables3m 40s
-
(Locked)
Shell parameter expansion3m 47s
-
(Locked)
Challenge: Looping and special variable operators1m 12s
-
(Locked)
Solution: Looping and special variable operators2m 23s
-
(Locked)
Challenge: sed and AWK1m 33s
-
(Locked)
Solution: sed and AWK3m 17s
-
-
-