regex - 通过 linux shell 执行文本

标签 regex linux bash shell paste

当我给出列表文本时,linux命令有什么办法吗 啊啊啊啊啊.htm 4 bbbbbbbbbb.htm 5 .... 它会给我结果 啊啊啊啊啊啊啊_2.htm 啊啊啊啊啊啊啊_3.htm 啊啊啊啊啊啊啊_4.htm bbbbbbbbbb_2.htm bbbbbbbbbb_3.htm bbbbbbbbbb_4.htm bbbbbbbbbb_5.htm ... 非常感谢您的帮助!

最佳答案

像这样吗?

cat list.txt 
aaaaaaaaaa.htm 4
bbbbbbbbbb.htm 5
awk '{gsub(/.htm/,"",$1);for (i = 2; i<=$2;i++){printf "%s_%s.htm\n",$1,i}}' list.txt 
aaaaaaaaaa_2.htm
aaaaaaaaaa_3.htm
aaaaaaaaaa_4.htm
bbbbbbbbbb_2.htm
bbbbbbbbbb_3.htm
bbbbbbbbbb_4.htm
bbbbbbbbbb_5.htm

关于regex - 通过 linux shell 执行文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23098616/

相关文章:

mysql - 如何使用 spring-data-jpa 对具有持久关系的实体执行 native 查询

linux - 在 Bash 中获取 '~' 缩写路径

c# - 为什么调用 Tesseract 进程会导致该服务随机崩溃?

regex - 为什么这个正则表达式在 grep 中有效但在 sed 中无效?

java - 使用 java 删除 sgml 中的父标签(如果其中包含特定标签)

linux - 是否可以在 Linux x86 GAS 程序集中创建没有系统调用的线程?

java.io.IOException : Cannot run program "/bin/bash": error=24, 打开文件太多

Bash 数组变量 : [@] or [*]?

arrays - foreach 在 bash 中遍历关联数组只返回最后一个元素

php - 将街道地址解析为组件