课程: Linux: Bash Shell and Scripts

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

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

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

课程: 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…

内容