Using the eval command in Linux to run variables as commands
Thursday, 7 July 2022
Add Comment
There are probably a lot of Linux users who have never encountered the eval command. In fact, it’s not really a "command", but a bash built-in that’s meant to process the value of a variable as a command. For example, if you set up a variable that includes the command to display the current time in Sydney, Australia, it would probably look like this:
$ dt="TZ='Australia/Sydney' date"
You could then run it like this:
$ eval $dt
Thu Jul 7 06:32:14 AM AEST 2022
Doing that can save you the trouble of memorizing the date command syntax and specifying a time zone, but let’s look a little more closely at eval to see what else it can do for you.
from Network World https://ift.tt/FlqZLBo
Genrerating Link.... 15 seconds.
Your Link is Ready.
0 Response to "Using the eval command in Linux to run variables as commands"
Post a Comment