Bash Shell read file line by line and substring
#read one file line by line
for line in $(cat test1.txt);
do echo $line ;
done;
#while read split line by space
while read line
do
for word in $line
do echo $word
done;
done <test1.txt #string split or substring
input=type=abcdefg
echo $input;
#get abcdefg
echo $input | cut -d'=' -f
echo $input | cut -d'=' -f #${variable:startindex:len}
export str=""
output=${str::}
echo $output #${varible##*string} 从左向右截取最后一个string后的字符串
#${varible#*string} 从左向右截取第一个string后的字符串
#${varible%%string*} 从右向左截取最后一个string后的字符串
#${varible%string*} 从右向左截取第一个string后的字符串 #常用保留变量:
$HOME:当前用户的根目录路径
$PATH:PATH环境变量
$PWD:当前工作路径
$,$,$,…:第0个参数(shell脚本自身),第1个参数……
$RANDOM:-65536之间的整数 #大小写转换
HI=HellOecho "$HI" # HellOecho ${HI^} # HellOecho ${HI^^} # HELLOecho ${HI,} # hellOecho ${HI,,} # helloecho ${HI~} # hellOecho ${HI~~} #hELLo^大写,,小写, ~大小写切换重复一次只修改首字母,重复两次则应用于所有字母${file/dir/path}:将第一个 dir 提换为 path:/path1/dir2/dir3/my.file.txt${file//dir/path}:将全部 dir 提换为 path:/path1/path2/path3/my.file.txtBash Shell read file line by line and substring的更多相关文章
- How to build .apk file from command line(转)
How to build .apk file from command line Created on Wednesday, 29 June 2011 14:32 If you don’t want ...
- 解决Warning: unlink(/storage/cache/cache.catalog.language.1556158719): No such file or directory in /system/library/cache/file.php on line 68问题
ytkah在调试opencart项目时提示Warning: unlink(/storage/cache/cache.catalog.language.1556158719): No such file ...
- Shell脚本:while read line无法读取最后一行的问题
[1]Shell脚本:while read line无法读取最后一行的问题 刚刚利用shell脚本处理日志文件时,发现了一个问题:while read line无法读取到最后一行 通过编辑器可以看到待 ...
- SyntaxError: Non-UTF-8 code starting with '\xe5' in file ***.py on line 105, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for
用charles抓包时, 对抓到的html,放到pycharm中解析, 结果报错: SyntaxError: Non-UTF-8 code starting with '\xe5' in file * ...
- Java 8 Stream – Read a file line by line
In Java 8, you can use Files.lines to read file as Stream. c://lines.txt – A simple text file for te ...
- 安装Phoenix时./sqlline.py执行报错File "./sqlline.py", line 27, in <module> import argparse ImportError: No module named argparse解决办法(图文详解)
不多说,直接上干货! 前期博客 Apache版Phoenix的安装(图文详解) 问题现象 Traceback (most recent call last): File , in <module ...
- (C++) Assertion failed: !"Bad error code", file VMem.c, line 715
(C++) Assertion failed: !"Bad error code", file VMem.c, line 715 Misc error. myInterface F ...
- Traceback (most recent call last): File "setup.py", line 22, in <module> execfile(join(CURDIR, 'src', 'SSHLibrary', 'version.py')) NameError: name 'execfile' is not defined
在python3环境下安装robotframework-SSHLibraray报错: Traceback (most recent call last): File "setup.py&qu ...
- mysql InnoDB: Assertion failure in thread xxxx in file ut0mem.cc line 105
mysql InnoDB: Assertion failure in thread xxxx in file ut0mem.cc line 105 错误信息 InnoDB: Assertion fai ...
随机推荐
- 【C#】1.1 第1章学习要点
分类:C#.VS2015 创建日期:2016-06-14 教材:十二五国家级规划教材<C#程序设计及应用教程>(第3版) 一.配套源程序(VS2015版)的运行截图 VS2015版的配套源 ...
- MySQL常用SQL语句
一.数据库操作 1.创建数据库: Mysql> CREATE DATABASE databaseName; Mysql数据库的数据文件默认存放在/usr/local/mysql/var/目录下, ...
- 平衡二叉树---Shaolin
Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temp ...
- 那些教程没有的php2-对象
php.net 对象 在类定义内部,可以用 new self 和 new parent 创建新对象. 当把一个对象已经创建的实例赋给一个新变量时,新变量会访问同一个实例,就和用该对象赋值一样.可以用克 ...
- 关联规则-R语言实现
关联规则code{white-space: pre;} pre:not([class]) { background-color: white; }if (window.hljs && ...
- ssh 客户端远程vi文本文件中文乱码(亲测)
由于是生产环境,且非笔者控制,为了避免影响系统全局,仅对本session有效 export LANG="zh_CN.UTF-8"export LANG="zh_CN.GB ...
- Javascript中的Label语句
在javascript中,我们可能很少会去用到 Label 语句,但是熟练的应用 Label 语句,尤其是在嵌套循环中熟练应用 break, continue 与 Label 可以精确的返回到你想要的 ...
- ArcGIS制图之Subset工具点抽稀
制图工作中,大量密集点显示是最常遇到的问题.其特点是分布可能不均匀.数据点比较密集,容易造成空间上的重叠,影响制图美观.那么,如果美观而详细的显示制图呢? Subset Features(子集要素)工 ...
- Q:关于Outlook for CRM 中预览记录窗体的设置
问题: 如何在Outlook for CRM中,将实体记录的预览窗口的信息做调整? 解决方案: 在Outlook里,在打开实体后选择View=>Customize Reading Pane,这里 ...
- bootstrap 学习笔记
bootstrap作为当下的流行框架不知道它怎么能行呢? 之前也看过好多bootstrap的网上教程,可是发现光看真的记不住,说起来也真是忧桑~重点还是要自己做才是真正的印象深刻.后来我发现解析模板是 ...