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.

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

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

From the course: Linux: Bash Shell and Scripts

Start my 1-month free trial

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

(exciting music) - So our first challenge was to print out the command line argument, one per line. So let's see how we could do that. So we could do a while loop and we're gonna use dollar sign, pound which is the number of command line arguments. While that's greater than zero, we're gonna loop. And we're gonna echo out the first one and then do a shift. And then see if there's any left. If there's any left, we'll print out the first one and then shift, so let's run that. And we'll give it the sequence A through F, there we go. Each of the command line arguments, one per line. Our second challenge was to assign a variable called File a default value if TheFile wasn't set. So let's see how we could do that. So File is assigned and we're using the colon dash operation and that's just what it does. If the TheFile is null or not set, then File's gonna get tmp/data.file}. If TheFile is set it's gonna get TheFile. So we're gonna print out at the end what the value is in File and what the…

Contents