echo指令创建文件换行

  • 使用echo创建文件
    echo "aaaa" >> hello.txt
    以追加的形式打开或创建文件,将字段写入到hello.txt;
    echo "aaaa" > hello.txt
    将字段写入hello.txt 覆盖之前的文件内容.

  • 在echo创建文件时写入换行
    echo -e "aaaa\nbbbb" >> hello.txt
    -e 代表执行转义,-E代表禁止转义

有问题最好养成“找男人”的习惯,以下是manual:

NAME
       echo - display a line of text

SYNOPSIS
       echo [SHORT-OPTION]... [STRING]...
       echo LONG-OPTION

DESCRIPTION
       Echo the STRING(s) to standard output.

       -n     do not output the trailing newline

       -e     enable interpretation of backslash escapes

       -E     disable interpretation of backslash escapes (default)

       --help display this help and exit

       --version
              output version information and exit

       If -e is in effect, the following sequences are recognized:

       \\     backslash

       \a     alert (BEL)

       \b     backspace

       \c     produce no further output

       \e     escape

       \f     form feed

       \n     new line

       \r     carriage return

       \t     horizontal tab

       \v     vertical tab

       \0NNN  byte with octal value NNN (1 to 3 digits)

       \xHH   byte with hexadecimal value HH (1 to 2 digits)

       NOTE: your shell may have its own version of echo, which usually supersedes the version described here.  Please refer to your shell's documentation for details about the options
       it supports.

你可能感兴趣的:(Linux)