Illegal character processing in Linux command line

Time:2021-8-13

Characters like $, & in linux commands are illegal. What if you only want to display these special characters as general symbols in the command? Reference is required. There are three reference methods in Linux.

  1. Enclose in double quotation marks’ ‘, but this is not valid for’ $’.

    echo “Today is $(date)”

  2. Use single quotation marks’ ‘to stop the function of all special characters.

    echo ‘Today is $(date)’

  3. Backslash \ escape, which is common on many occasions.

    echo “Today is $(date)”

Output:

[[email protected] ~]# echo "Today is $(date)"
Today is Thursday, July 1, 2021 20:27:00 CST
[[email protected] ~]# echo 'Today is $(date)'
Today is $(date)
[[email protected] ~]# echo "Today is $(date)"
Today is $(date)

Recommended Today

Learn to use global parameters and directory parameters in apipost in one minute

Global and catalog parameters In the previous example, we filled in different request header, query and body parameters in a single interface. However, in actual projects, a batch of interfaces often have the same request parameters. At this point, we can use global parameters or directory parameters. For example, for common token parameters, if we […]