linux - 该脚本中 -e 标志的用途是什么?

标签 linux bash unix

我从 - http://www.thegeekstuff.com/2010/06/bash-conditional-expression/ 那里得到了一个脚本

是-

$ cat exist.sh
#! /bin/bash
file=$1
if [ -e $file ]
then
    echo -e "File $file exists"
else
    echo -e "File $file doesnt exists"
fi

$ ./exist.sh /usr/bin/boot.ini
File /usr/bin/boot.ini exists

我在 echo 附近使用了相同的代码,但没有 -e 并且它可以工作。那么,使用 -e 的目的是什么?

最佳答案

-e 标志可以解释以下反斜杠转义的内容 每个字符串中的字符:

\a          alert (bell)

\b          backspace

\c          suppress trailing newline

\e          escape 

\f          form feed

\n          new line

\r          carriage return

\t          horizontal tab

\v          vertical tab

\\          backslash

\NNN
      the character whose ASCII code is NNN (octal); if NNN is not
      a valid octal number, it is printed literally.

\xnnn
      the character whose ASCII code is the hexadecimal value 
      nnn (one to three digits)

来源:http://ss64.com/bash/echo.html

关于linux - 该脚本中 -e 标志的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18002282/

相关文章:

linux - 在Ubuntu中安装应用程序时出现错误 "Waiting for cache lock: Could not get lock/var/lib/dpkg/lock-frontend"

c - 将 "*()"作为参数传递给 bash 中的程序

bash - 更正 Bash 和 shell 脚本变量大小写

ruby - 按名称查找进程 ID

linux - 如何在CentOS中安装 "libhyperic-sigar-java"

linux - 在终端中输入 "bash -v"命令后出现问题

bash - 将多个 stdout 命令重定向到一个文件

linux - 如何用包含换行符的字符串替换文件内容?

linux - 在 Linux 中选择 csv 中的缩写

linux - 带有空白字符的 bash 环境变量。 cd 不带引号