Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. eval - construct command by concatenating arguments
  2.  
  3. 1) foo=10 x=foo
  4. 2) y='$'$x
  5. 3) echo $y
  6. 4) $foo
  7. 5) eval y='$'$x
  8. 6) echo $y
  9. 7) 10
  10.  
  11. eval [arg ...]
  12. The args are read and concatenated together into a single com-
  13. mand. This command is then read and executed by the shell, and
  14. its exit status is returned as the value of eval. If there are
  15. no args, or only null arguments, eval returns 0.
  16.  
  17. andcoz@...:~> $( echo VAR=value )
  18. bash: VAR=value: command not found
  19.  
  20. andcoz@...:~> eval $( echo VAR=value )
  21. andcoz@...:~> echo $VAR
  22. value
  23.  
  24. eval [arg ...]
  25. The args are read and concatenated together into a single command.
  26. This command is then read and executed by the shell, and its exit
  27. status is returned as the value of eval. If there are no args, or only
  28. null arguments, eval returns 0
  29.  
  30. eval: eval [arg ...]
  31. Execute arguments as a shell command.
  32.  
  33. Combine ARGs into a single string, use the result as input to the shell,
  34. and execute the resulting commands.
  35.  
  36. Exit Status:
  37. Returns exit status of command or success if command is null.
  38.  
  39. /home/user1 > a="ls | more"
  40. /home/user1 > $a
  41. bash: command not found: ls | more
  42. /home/user1 > # Above command didn't work as ls tried to list file with name pipe (|) and more. But these files are not there
  43. /home/user1 > eval $a
  44. file.txt
  45. mailids
  46. remote_cmd.sh
  47. sample.txt
  48. tmp
  49. /home/user1 >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement