echo命令
Posted godlove
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了echo命令相关的知识,希望对你有一定的参考价值。
a=ddd
echo $a
echo a
echo $p
echo $PATH
which find
which adb
echo $PATH
[ 2 -gt 1 ]
echo $?
ls
a=1
echo $a
b=hello world
b="hello world"
echo $b
echo b
a=‘hello world‘
a
echo $a
b=1
echo "abc $a"
echo ‘abc $a‘
echo "bac $a"
c="today is sunday"
echo "hello,$c"
echo ‘hello,$c‘
echo $ddd
a="hello"
echo $a_1
echo $a _1
echo $a_1
b="sunday"
ehco $b
echo $b
pwd
$PWD
echo $PWD
echo $USER
echo $path
echo $PATH
echo $home
echo $HOME
a=1
b=(1 2 3 4 5)
echo $a
echo $b
echo $a[*]
echo $b[*]
echo $b[4]
echo $#b[*]
which python
which 1.sh
ls
which file.out
a=`ls`
echo $a
ls
array=(`ls`)
echo "print(3*7)" | python
echo $array
echo $array[*]
echo $#array[*]
echo $array[6]
echo $array[-1]
echo "a\nbbb"
echo -e "a\nbbbb"
echo "a\\"bbbb"
my dir is `ls`
echo my dir is `ls`
echo my dir is $ls
echo my dir is $(ls)
a=4;b=7
echo $((a+b))
echo $(($a+$b))
echo $((a-b))
echo $(3+2)
echo $((3+5))
a=4;b=2;c=3
echo $((a+b*c))
a="hello world is a happy day"
echo $a
echo hello world luming com
a=33444
echo $a
echo $((a+2))
echo $((4+a))
echo $((a/4))
echo $((a*6))
a=5
((a=a+5))
echo $a
((a=a*6))
echo $a
((a++));echo $a
((a--));echo $a
a=4;b=6
((a<b))
echo $?
((a>b))
echo $?
echo $((2/3))
echo $((3/2))
awk ‘BEGINprint 2/3‘ 除数支持浮点数据
s="hello from china"
echo $s
echo $6
echo $s
echo $:6
echo $s:6
echo $s:6:3
echo $s:6:5
echo $#s
echo $s
echo $s#hello
echo $s
echo "$s#china"
echo "$s#chinaa"
echo "$s#ccc"
echo "$s#*m"
echo "$s#*l"
echo "$s#*a"
echo "$s#*n"
echo "$s#*o" *放在前面
echo "$s##*o" 贪婪匹配,匹配至最后一个(掐头)
echo "$s%na" 去尾
echo "$s%h*" *放在后面
echo "$s%%o*" 贪婪匹配
echo "$s/china/shanghai" china为被替换的内容,shanghai为替换的内容
echo -e "1|2|3\n4|5|6\n7|8|9" 输出的结果为:
1|2|3
4|5|6
7|8|9
以上是关于echo命令的主要内容,如果未能解决你的问题,请参考以下文章