用shell简单处理文本的例子
来源:互联网 发布:淘宝介入后买家输后果 编辑:程序博客网 时间:2024/05/25 12:21
用shell简单处理文本的例子
text_process.sh
#!/bin/shIFS=:echo "example of text processing using shell"echo "--------------------------------------"while read name age universitydoecho "$name is from $university, $age"done < ./raw_txt.txt
raw_txt.txt
zhang san:20:Hunan Univerisityli si:21:Tsinghua Univerisitywang wu:22:Wuhan Univerisity执行:
xxx:/work/shell/text_process$ sh text_process.sh > result.txt
xxx:/work/shell/text_process$ cat result.txt
example of text processing using shell
--------------------------------------
zhang san is from Hunan Univerisity, 20
li si is from Tsinghua Univerisity, 21
wang wu is from Wuhan Univerisity, 22
注意:
1. 上面IFS=:指定了name、age、university shell变量之间的分割符。
2. 当读到最后一行时while条件不符合,结束循环。
3. while done后面的 < ./raw_txt.txt是重定向while read的输入。
0 0
- 用shell简单处理文本的例子
- 简单的文本处理
- 简单的文本处理
- 简单的文本处理
- 简单的文本处理
- 简单的文本处理
- 简单的shell scripts例子
- 用RNN生成文本的简单例子(过程详细)
- Linux简单的文本处理
- 简单的文本处理命令
- Shell常用的文本处理命令总结
- 常见处理文本的SHELL命令
- shell中对文本的一些处理
- 【shell】文本处理的一些小技巧
- shell文本处理
- shell 文本处理
- shell文本处理
- shell文本处理
- 第三周项目:标准体重
- Ubutun 下的MySQL安装
- Java 设计模式-工厂模式
- Mac常用快捷键+设置
- Spring Ioc-依赖注入的几种方式
- 用shell简单处理文本的例子
- kmp算法c++实现
- MySQL之数据类型
- POJ 3461 Oulipo
- C语言练习题
- View平移动画的正确写法
- Jedis源码解析(ShardedJedis)
- Unity3d 开发(十)使用uTomate自动化打包流程
- JDK的安装与环境变量配置