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

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.

Contents