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.
Using the eval and getopt commands - Linux Tutorial
From the course: Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation
Using the eval and getopt commands
- [Instructor] Let's look at a couple of kind of complicated commands, but you want to be aware of them. First one is eval. So it says bash evaluates a string. So that means the string can be a command or set variables. So it's kind of a second pass over the string so that it could be executed. You could think of it as executing data, so be careful what's in there because it could be commands that do bad things. So don't just like ask a user to type something in and then eval it. 'cause they could have typed in something you don't want. Maybe you've seen something like this. Ssh- agent -s running that. So that command is going to output these assignments to variables, and then when you eval that output, it's actually going to do those assignments of variables. If you think about it, you can't just run that and have it happen. It's going to print out those assignments. It's not going to do 'em. It's the eval that does 'em. It does the output of the command. And then we have getopt…
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 22s
-
(Locked)
Debugging scripts with -x and -u options3m 12s
-
(Locked)
Signals and traps2m 38s
-
(Locked)
Using the eval and getopt commands3m 57s
-
(Locked)
Challenge: Debugging scripts and using trap and eval1m 21s
-
(Locked)
Solution: Debugging scripts and using trap and eval2m 8s
-
(Locked)
Challenge: getopt, trap, and coproc3m 4s
-
(Locked)
Solution: getopt, trap, and coproc4m 13s
-
(Locked)
-