《Shell Programming in Unix, Linux and OS X, 4th Edition 》 笔记之Can I Quote You On That?
来源:互联网 发布:php发送短信 编辑:程序博客网 时间:2024/06/06 03:13
命令替换
There are two ways in the shell to perform command substitution: by enclosing the command in back quotes or surrounding it with the
wdy@wdy:~$ echo The date and time is 'date'The date and time is datewdy@wdy:~$ echo The date and time is "date"The date and time is datewdy@wdy:~$ echo The date and time is `date`The date and time is 2017年 01月 18日 星期三 15:24:25 CSTwdy@wdy:~$ echo The date and time is $(date)The date and time is 2017年 01月 18日 星期三 15:35:59 CST
$(…)允许嵌套以及管道命令。
wdy@wdy:~$ echo "you have $(who | wc -l) peopele"you have 17 peopele
当filelist被shell替换的时候,里面的回车符号被去掉了
$ filelist=$(ls)$ echo $filelistaddresses intro lotsaspaces names nu numbers phonebook stat$ echo "$filelist"addressesintrolotsaspacesnamesnunumbersphonebookstat$
$ name="Ralph Kramden"$ name=$(echo $name | tr '[a-z]' '[A-Z]')$ echo $nameRALPH KRAMDEN$
$ file=exec.o$ lastchar=$(echo $file | sed 's/.*\(.\)$/\1/')$ echo $lastcharo$
$ filename=/users/steve/memos$ filename=$(echo $filename | tr "$(echo $filename | cut -c1)" "^")$ echo $filename^users^steve^memos$
0 0
- 《Shell Programming in Unix, Linux and OS X, 4th Edition 》 笔记之Can I Quote You On That?
- 《Shell Programming in Unix, Linux and OS X, 4th Edition 》 笔记之Passing Arguments
- 《Shell Programming in Unix, Linux and OS X, 4th Edition 》 笔记之Decisions,Decisions
- Practical Programming in Tcl and Tk (4th Edition)
- Bash/KSH/SH Shell: Find The Length Of a String On a UNIX, Linux, BSD, and OS X
- [linux and unix shell programming] and [the unix environment programming]
- Unix Shell Programming, Third Edition
- DB2 SQL PL : Essential Guide for DB2 UDB on Linux, UNIX, Windows, i5/OS, and z/OS, Second Edition
- Beginning Linux Programming 4th Edition 学习笔记 - Chapter 1:Getting started
- 《beginning linux programming 4th edition》中文翻译(一)
- Thinking in java 4th Edition 读书笔记-I/O(4)
- Thinking in java 4th Edition 读书笔记-I/O(1)
- Thinking in java 4th Edition 读书笔记-I/O(2)
- Thinking in java 4th Edition 读书笔记-I/O(3)
- Thinking in java 4th Edition 读书笔记-I/O(5)
- Thinking in java 4th Edition 读书笔记-I/O(6)
- Programming in Shell -- I
- Symbian development on Linux and OS X
- 安卓视屏录制MediaRecorder
- TortoiseGit安装与配置
- bootsect.S 中文注释 ( linux-0.12 )
- Maven仓库镜像
- zoj1089
- 《Shell Programming in Unix, Linux and OS X, 4th Edition 》 笔记之Can I Quote You On That?
- Android的Handler部分原理的解析
- unity 检测 任意半径球体内的所有物体( 碰撞体)
- c——作用域 生命周期 存储区域
- java学习笔记(一)
- Android开发进阶—View的滑动
- BZOJ 2120: 数颜色 && 2453: 维护队列 【带修莫队版题【也可以学黄学长分块
- 自定义指令的隔离作用域
- bootstrap——css样式(四、表单)