美文网首页
类Unix 基础命令整理(二)

类Unix 基础命令整理(二)

作者: will2yang | 来源:发表于2018-01-07 22:01 被阅读0次

echo

# 当 要输出的文本里有引号时 可以另外一种引号来包裹 比如有 ' 可以用 " 包裹在两侧
$ echo Let's see if this'll work
# Lets see if thisll work
$ echo "This is a test to see if you're paying attention"
#this is a test to see if you're paying attention

#加上 -n 后要显示的命令后有 空格 那么之后的命令会紧接着输出
#!/bin/bash
echo -n "The time and date are: "
date
#The time and date are: Mon Feb 21 15:42:23 EST 2014

set 显示一份完整的当前环境变量列表

#!/bin/bash
#在环境变量名之前加上($)来使用这些环境变量
echo "User info for userid: $USER"
echo UID: $UID
echo HOME: $HOME

#$符存在的问题 使用\转译
$ echo "The cost of the item is $15"
#The cost of the item is 5
$ echo "The cost of the item is \$15"
#The cost of the item is $15

用户变量的设置

#shell脚本会自动 定变量 的数据  
var1=10
var2=-57
var3=testing
var4="still more testing"
#!/bin/bash

days=10
guest="Katie"
echo "$guest checked in $days days ago"
days=5
guest="Jessica"
echo "$guest checked in $days days ago"
#Katie checked in 10 days ago
#Jessica checked in 5 days ago
#!/bin/bash
value1=10
value2=$value1
echo The resulting value is $value2
#The resulting value is 10

chmod

chmod u+x test1 #给文件的所有者添加可执行创建

相关文章

网友评论

      本文标题:类Unix 基础命令整理(二)

      本文链接:https://www.haomeiwen.com/subject/oavmnxtx.html