Seeing The World As The Shell Sees It
来源:互联网 发布:科比0506常规赛数据 编辑:程序博客网 时间:2024/05/22 11:39
Here we will introduce one command:
echo:display a line of text
Expansion
For example “*”,can have a lot of meaning to the shell.The process that makes this happen is called expansion.
echo
echo is a shell built that performs a very simple task.example:
echo this is a text
echo *
can’t print ““,in privious character means match any characters in a filename.The shell expanse the “*” into something else before the echo command is executed.When the enter key is pressed,the shell expands any qualifying characters on the command line before the command is carried out.example:
echo [[:upper:]]*## will show all the file that beginning with an upper character
echo /usr/*/share## "*" expanse everything you can image~
want to expanse hiden file?,OK:
echo .*
but this command will show ‘.’ and ‘..’ this two.If I don’t want show current directory and parent directory,I can try:
echo .[!.]*
this will work correctly in most files.It still can’t include filenames with multiple leading periods,so if you want to show a correct listing of hidden files:
ls -A
Tilde Expansion
the ~ character means the home directory of the current user:
echo ~
if user ‘wuxiao’ has an account,then:
echo ~wuxiao## it is the same of 'echo ~' with 'wuxiao' user
Arithmetic Expansion
we can use the shell prompt as a calculator
echo $((2+2))
Arithmetic expansion use the form:
$((expression))
Arithmetic operators:
- +
- -
- *
- /
- ** :Exponentiation
example:
echo $(($((5**2))*3))echo $((5**2*3))echo $(((5**2)*3))##output is 75
echo ((5/2))##will display 2
Brace expansion
with brace,you can create multiple text strings from a pattern containing braces,example:
echo Front - {A,B,C} - Back## will show 'Front - {A,B,C} - Back'
using a range of integers:
echo Number_{1..5}##will show Number_1 Number_2 ... Number_5
also can be zero-padded like:
echo {001..6}##001 002 003 ... 006echo {z..a}##z y x ... a
The most common application is to make lists of files or directories to be created:
mkdir {2015..2017}-{01..12}
Parameter expansion
Use variable to store small chunks of data and to give each chunk a name.
echo $USERprintenv | lessecho $(ls)
Quoting
echo this is a test##this is a testecho the total is $100.00##the total is 00.00
Shell will remove the extra whitespace from the echo command’s arguments.example 2 shell will treat ‘$1’ as a parameter expasion.SO what should we do if we want to leave the origin output?
Use Double Quotes
ls -l "two words.txt"mv "two words.txt" two_words.txtecho "$USER "\$100.00" $(cal)"
Single Quotes
If we need to suppress all expansions,we use single quotes:
echo '23467567*&!~@$%}{}|?/\6346'
Escaping Characters ‘\’
Just like the function in C.Here are some frequent examples:
- \a:Bell
- \b:Backspace
- \n:NewLine
- \r:Carriage return
- \t:Tab
- Seeing The World As The Shell Sees It
- The Linux Command Line 读书笔记 第七章 Seeing The World As The Shell Sees It
- How China sees the world
- The World As I See It -----Albert Einstein
- The World As I See It ------ Albert Einstein
- President Obama on the Passing of Steve Jobs: He changed the way each of us sees the world
- 【每天读一点英文】gnuhpc:The World As I See It(节选)
- Product Manager: Seeing Through the Cloud
- THE WORLD
- Fedora23 - Broadcom not seeing specific wifi [sees others]
- Seeing numbers in Ruby with r attached to the number
- Vision and Art ,The Biology of Seeing 读书笔记
- Seeing the Big Picture:Deep Embedding with Contextual Evidences
- The two numbers and return it as a linked list
- Profiling Hackers: The Science of Criminal Profiling as Applied to the World of Hacking
- awk:the most powerful utility tool in shell world.
- The angel in the world!!
- abercrombie paris Now what measures to protect the languages � f the world have it
- ArrayList LinkedList源码分析,性能分析
- ARM学习之Nand FLash控制器
- Java内存模型
- Dubbo RPC原理解读
- compare函数的使用
- Seeing The World As The Shell Sees It
- 使用maven生成可执行的jar包
- 利用jsoncpp接口来实现json字串的序列化与反序列化的C++封装类
- 觉得自己好弱
- STM8L15x系列单片机判断指定I/O引脚电平
- 畅通工程(并查集)
- Eclipse启动Tomcat时server.xml和content.xml自动还原问题
- java android 中的接口回调
- Pow(x, n)