shell提取目录下所有文件中某个开头的字符串输出到一个文件中

  1. 自己建一个xxx.sh的文件,然后把下面的path改成你要查找的目录。
  2. 我这里要查找的是20231018_开头的字符串到"双引号结束例如,
bash 复制代码
#!/bin/bash
path="C:/Users/user/AppData/Roaming/npm/node_modules自己的文件目录" 
ls $path | while read line
do
file=${path}${line}
cat ${file} | grep "20231018" | awk -F'20231018_' '{print $2}' | awk -F'"' '{print $1}' >> string.txt
done
相关推荐
EverydayJoy^v^14 天前
Linux Shell 高级编程(3)——awk
linux·运维·shell
dingdingfish17 天前
Bash学习 - 第10章:Installing Bash
bash·make·shell·install·configure·5.3
dingdingfish18 天前
Bash学习 - 第8章:Command Line Editing,第6-8节:Programmable Completion
bash·shell·completion·complete·compgen·compopt
白云偷星子19 天前
RHCSA笔记3
shell
dingdingfish20 天前
Bash学习 - 第7章:Job Control
bash·shell·wait·job
dingdingfish20 天前
Bash学习 - 第8章:Command Line Editing,第1-2节:Intro & Readline Interaction
bash·shell·readline
only_Klein20 天前
Shell 三剑客
shell·sed·grep·awk
dingdingfish21 天前
Bash学习 - 第6章:Bash Features,第12节:Shell Compatibility Mode
bash·shell·compat·compatibility
alanesnape21 天前
一个支持在线deBug的编辑器/调试器功能详解
shell·在线编译器·在线debug
dingdingfish22 天前
Bash学习 - 第6章:Bash Features,第10节:The Restricted Shell
bash·shell·rbash·restrict