Linux下为文件增加列的shell脚本
来源:互联网 发布:vc 多线程编程 编辑:程序博客网 时间:2024/06/06 00:33
场景:linux有份文件,需要增加一列序号来标记,通过shell脚本来实现。
步骤:
1)创建一份test.txt文件,内含一列,如下:
bash-4.1$ cat test.txtabcde
2)创建脚本row_id.sh,如下:
bash-4.1$ cat row_id.sh#!/bin/shlines=$1for ((i=1;i<=$lines;i++))do echo $i>>test_id.txtdone
3)执行脚本:sh row_id.sh 5
生成5行序号,如下:
bash-4.1$ cat test_id.txt12345
4)合并两份文件,执行:
paste test_id.txt test.txt > test_and_id.txt
5)查看最终结果:
bash-4.1$ cat test_and_id.txt1 a2 b3 c4 d5 e
阅读全文
0 0
- Linux下为文件增加列的shell脚本
- linux下的shell脚本
- Linux下的SHELL脚本
- Linux下为可执行shell脚本文件(.sh),制作桌面启动快捷方式
- linux shell脚本增加#!/bin/sh导致的问题
- 增加系统安全的shell脚本
- 为VMware下的linux增加空间
- Linux shell编程 5 ---- 利用shell脚本遍历某个目录下的所有文件
- linux下shell脚本
- 遍历目录下的文件---shell脚本
- 让Linux下的cron以秒为单位执行shell脚本的3种方法
- linux 下的Shell 脚本书写语法
- Linux下Shell脚本的课堂笔记
- linux下的shell脚本编写
- Linux下简单Shell 脚本的写法
- 简单的linux下shell启动脚本
- Linux环境下的脚本—shell
- Linux下Shell脚本的调试
- 170626 逆向-Crackme之005
- debian安装apache2成功之后,在web请求显示的文档 翻译
- VMware虚拟网卡
- SICP-2.2-String
- LeetCode 66. Plus One
- Linux下为文件增加列的shell脚本
- 论文《Recurrent Convolutional Neural Networks for Text Classification》总结
- 将自己的时间戳转换为几分钟前,几小时前,几天前
- com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: java.security.cert.CertP
- No content to map due to end-of-input
- 使用Tomcat搭建最简单的服务器
- ubuntu控制mysql
- EventBus使用详解(二)——EventBus使用进阶
- 数据库多层数据运用递归算法生成树形数据