Usage of the Linux command eval

Source: Internet
Author: User

1. Eval command-line

whichCommand- Lineis a normal command line typed on the terminal. But when you put it in front of it, EvalThe result is that the shellscan it two times before executing the command line. such as:

Pipe= "|"

Eval ls $pipe wc-l

shell 1 When the command line is scanned, it replaces the pipe < Span style= "Font-family:times New roman;word-wrap:break-word" >eval Let it scan the command line again, when shell | as a pipe symbol.

If the variable contains any required Shell characters you see directly on the command line (not the result of a substitution), you can use the eval . command line terminator (; | & ),I /o Redirection (< > ) and the quotation marks belong to the Shell symbols that have special meanings must appear directly on the command line.

2. Eval echo \$$# to get the last parameter

such as: Cat Last

Eval echo \$$#

./last one, three four

four

After the first scan, shell Shell When the row is scanned again, it replaces the $4 echo command

3. The following shows how to use eval command creates a pointer to a variable:

x=100

Ptrx=x

eval echo \$ $ptrx   Point to b

100&NBSP; print Span style= "Word-wrap:break-word" >100

eval $ptrx =50  will 50 save to ptrx

Echo $x

- Print -


Use of the Linux command eval

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.