Linux command’s Array
#数组的声明与遍历
animals=("a dog" "a cat" "a fish")
#wrong ways to use this
for i in ${animals[*]}; do echo $i; done
for i in "${animals[*]}"; do echo $i; done
#this is what we want correct way to use
for i in "${animals[@]}"; do echo $i; done
#数组元素的排序
a=(f e d c b a)
echo "Original array: ${a[@]}"
a_sorted=($(for i in "${a[@]}"; do echo $i; done | sort))
echo "Sorted array: ${a_sorted[@]}"
#删除数组长或数组的某个元素
foo=(a b c d e f)
echo ${foo[@]}
unset foo[2]
echo ${foo[@]}
cut 命令从文件的每一行剪切字节、字符和字段并将这些字节、字符和字段写至标准输出。
主要参数
-b :以字节为单位进行分割。这些字节位置将忽略多字节字符边界,除非也指定了 -n 标志。
-c :以字符为单位进行分割。
-d :自定义分隔符,默认为制表符。
-f :与-d一起使用,指定显示哪个区域。
-n :取消分割多字节字符。仅和 -b 标志一起使用。如果字符的最后一个字节落在由 -b 标志的 List 参数指示的<br />范围之内,该字符将被写出;否则,该字符将被排除。
#split string to array one demo
foo="hello world hello java hello docker hello spark hello stream"
declare -A bar
read -a bar <<<$foo
Linux command’s Array的更多相关文章
- 《The Linux Command Line》 读书笔记04 Linux用户以及权限相关命令
Linux用户以及权限相关命令 查看身份 id:Display user identity. 这个命令的输出会显示uid,gid和用户所属的组. uid即user ID,这是账户创建时被赋予的. gi ...
- 《The Linux Command Line》 读书笔记02 关于命令的命令
<The Linux Command Line> 读书笔记02 关于命令的命令 命令的四种类型 type type—Indicate how a command name is inter ...
- 《The Linux Command Line》 读书笔记01 基本命令介绍
<The Linux Command Line> 读书笔记01 基本命令介绍 1. What is the Shell? The Shell is a program that takes ...
- Linux Command Line Basics
Most of this note comes from the Beginning the Linux Command Line, Second Edition by Sander van Vugt ...
- Linux Command Line 解析
Linux Command Line 解析 0 处理模型 Linux kernel的启动包括很多组件的初始化和相关配置,这些配置参数一般是通过command line进行配置的.在进行后续分析之前,先 ...
- 15 Examples To Master Linux Command Line History
When you are using Linux command line frequently, using the history effectively can be a major produ ...
- 10 Interesting Linux Command Line Tricks and Tips Worth Knowing
I passionately enjoy working with commands as they offer more control over a Linux system than GUIs( ...
- Reso | The Linux Command Line 的中文版
http://book.haoduoshipin.com/tlcl/book/zh/ 本书是 The Linux Command Line 的中文版, 为大家提供了多种不同的阅读方式. 中英文双语版- ...
- [笔记]The Linux command line
Notes on The Linux Command Line (by W. E. Shotts Jr.) edited by Gopher 感觉博客园是不是搞了什么CSS在里头--在博客园显示效果挺 ...
随机推荐
- sencha 报错问题汇总
store的url必填 否则报错:Uncaught TypeError: Cannot read property 'indexOf' of undefined ext-all.js store必须在 ...
- SqlServer定时备份数据库和定时杀死数据库死锁解决
上周五组长对我说了一句要杀死数据库的死锁进程,有时候同一时刻不停写入数据库会造成这种情况的发生,因为自己对数据库不是很熟悉,突然组长说了我也就决定一定要倒腾一下,不然自己怎么提高呢?现在不研究,说不定 ...
- 【iOS】Quartz2D图形上下文
一.绘图的完整过程 程序启动,显示自定义的view.当程序第一次显示在我们眼前的时候,程序会调用drawRect:方法,在里面获取了图形上下文(在内存中拥有了),然后利用图形上下文保存绘图信息,可 ...
- rabbitmq学习笔记2 基本概念
官网:http://www.rabbitmq.com 参考:http://blog.csdn.net/column/details/rabbitmq.html 1 基本概念 rabbitmq se ...
- windows临界区
临界区: 临界区是一种轻量级机制,在某一时间内只允许一个线程执行某个给定代码段.通常在多线程修改全局数据时会使用临界区.事件.信号量也用于多线程同步,但临界区与它们不同,并不总是执行向内核模式的切换, ...
- js argument实参集合与局部变量、参数关系
形参 形式上传递的参数 function fn1(a,b,c) {//a,b,c就是形参 实参 实际传递的参数 fn1 (1,2,5);//1,2,5就是实参 argument 定义: 实参的集合 用 ...
- css导航栏
几个导航栏也算对学过知识的回顾,总有新的收获,下面是学习过程中敲的代码: <!DOCTYPE HTML> <html> <head> <title>&l ...
- Ieditor
Interfaces Description IActiveViewEvents (esriCarto) Provides access to events that occur when the s ...
- 读取XML绑定TreeNode
<asp:TreeView ID="treeview" OnClick="TreeViewCheckBox_Click()" runat="se ...
- mysql innoDB 挂了的临时解决方案
Mysql InnoDB: Error: checksum mismatch by Mattias Hemmingsson on December 23, 2013 in Linux • 6 Comm ...