From the course: Linux: Bash Shell and Scripts
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Challenges: Debugging scripts using trap, eval, getopt, and coproc - Linux Tutorial
From the course: Linux: Bash Shell and Scripts
Challenges: Debugging scripts using trap, eval, getopt, and coproc
- [Voiceover] Let's write a Bash script that's gonna trying usin' the eval command. So we want you to have a variable c assign the string with the quote ls -s piped in to sort -n. So ls -s will produce a list of the files with their size in front and then sort -n will sort numerically. Might be kind of handy to pipe that in detailed to see the big ones. So try running that just to saying $c and see what happens. Then try running with eval $c Then try running with eval $c and see what happens. Now let's use eval with set. So in a script assign to opts the string, a space b space \$1 space \$2. Then do set -- $opts Then do set -- $opts and echo out what your arguments are now with echo $@. So maybe we would see a b x y because when we run the script with x y z x and y are first two arguments. See what happens. Then in your script change the set to have an eval in front of it and run it again and see what you get when you echo out $@. Let's modify our options.sh script and add a couple…
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
-
-
-
-
-
-
(Locked)
Using the coproc command5m 53s
-
(Locked)
Debugging scripts with -x and -u options4m
-
(Locked)
Signals and traps4m 14s
-
(Locked)
Using the eval and getopt commands6m 47s
-
(Locked)
Challenges: Debugging scripts using trap, eval, getopt, and coproc2m 49s
-
(Locked)
Solutions: Debugging scripts using trap, eval, getopt, and coproc7m 22s
-
(Locked)
-