简体   繁体   English

过滤所有子目录中的文件并以相同的名称保存?

[英]Filter files in all subdirectories and save them with the same name?

How to remove duplicate lines in every file in directory and save the fixed data in the same file with a single line command?如何使用单行命令删除目录中每个文件中的重复行并将固定数据保存在同一文件中?

the following do not work:以下不起作用:

   find . -type f -execdir cat {} | sort | uniq > {} \; 

   find . -type f | xargs -I{} cat {} | sort | uniq > {}

   find . -type f | xargs -I{} cat {} | sort | uniq > {}.new && mv {}.new {}

the '>' symbol breaks the chain.. '>' 符号打破了链条..

Put a shell wrapper in the exec:将 shell 包装器放入 exec 中:

find . -type f -exec sh -c 'sort "$1" | uniq > "$1.new" && mv "$1.new" "$1"' _ {} \;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将多个同名文件从所有子目录移动到一个新位置时如何重命名它们 - How to rename multiple files with the same name when moving them from all subdirectories into one new location 如何在所有子目录中找到所有具有相同名称的文件 - how do i find all files with the same name in all subdirectories 在子目录中搜索相同文件,并在所有子目录中替换字符串 - search same file in subdirectories and replace string in all of them 合并具有相同名称的子目录 - merging subdirectories with the same name 如何将所有文件按扩展名移动到指定DIR目录中的子目录? - How to move all files to subdirectories by extension name in the specified DIR directory? 查找所有扩展名为.sh .cpp .c的文件,并将其复制到我的桌面目录中,如果存在同名文件,则将其重命名 - find all files with .sh .cpp .c extension and copy them to a directory in my desktop, if there is a file with the same name, rename it 如何在列表中查找包含使用部分名称的目录和子目录中的所有文件,然后将它们复制到新文件夹 - How to find all files in a directory and subdirectories that contain using partial names within a list then copy them to a new folder 复制所有子目录的递归文件 - Copy recursive files of all the subdirectories php获取所有子目录和所有文件的列表 - php get list of all subdirectories and all files 解压终端所有子目录下的所有gz文件 - Unzip all gz files in all subdirectories in the terminal
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM