Linux shell中将多行内容赋值给一个变量 && 常用的转移字符

[root@localhost home]# vim test.sh 
#!/bin/sh


#  \n    newline
#  \r    Enter
#  \t  
#  \v
#  \b    backspace
#  \a    bip
#  \xFF  \x00~\xFF


CUR_DIR=`pwd`
target=$CUR_DIR/abc/list/files.txt

newline=$'\n'
newline2=$'\x0a'
a=$'\x61'


ret="$newline============ version ===========$newline"

if [ -e $target ]; then
  ret+= "$(cat $target )"
else
  ret+="File or directory not exist."
fi

  ret+= "$newline2"
  ret+= "$a"

echo "$ret"


[root@localhost home]# ./test.sh 


============ version ===========
Version: 1.0
Compile-Timestamp: 2017-04-10 20:01:30
Java Version: 1.6
a
[root@localhost home]# 



你可能感兴趣的:(Linux,常见问题)