From the course: Linux: Bash Shell and Scripts

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenges: Looping, special variable operators, sed, and AWK

Challenges: Looping, special variable operators, sed, and AWK - Linux Tutorial

From the course: Linux: Bash Shell and Scripts

Start my 1-month free trial

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…

Contents