Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- eval - construct command by concatenating arguments
- 1) foo=10 x=foo
- 2) y='$'$x
- 3) echo $y
- 4) $foo
- 5) eval y='$'$x
- 6) echo $y
- 7) 10
- eval [arg ...]
- The args are read and concatenated together into a single com-
- mand. This command is then read and executed by the shell, and
- its exit status is returned as the value of eval. If there are
- no args, or only null arguments, eval returns 0.
- andcoz@...:~> $( echo VAR=value )
- bash: VAR=value: command not found
- andcoz@...:~> eval $( echo VAR=value )
- andcoz@...:~> echo $VAR
- value
- eval [arg ...]
- The args are read and concatenated together into a single command.
- This command is then read and executed by the shell, and its exit
- status is returned as the value of eval. If there are no args, or only
- null arguments, eval returns 0
- eval: eval [arg ...]
- Execute arguments as a shell command.
- Combine ARGs into a single string, use the result as input to the shell,
- and execute the resulting commands.
- Exit Status:
- Returns exit status of command or success if command is null.
- /home/user1 > a="ls | more"
- /home/user1 > $a
- bash: command not found: ls | more
- /home/user1 > # Above command didn't work as ls tried to list file with name pipe (|) and more. But these files are not there
- /home/user1 > eval $a
- file.txt
- mailids
- remote_cmd.sh
- sample.txt
- tmp
- /home/user1 >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement