[英]How to read the column of text file using Linux shell script and copy the files to another path with in sub directories
[英]Linux - copy files if column 5 in a file contains "V"
我有許多 csv 文件(如 tmo_2019*)。 在這些文件中,一些文件的第 5 列值為 V。我想將那些具有第 5 列值為 V 的文件復制到特定目錄 /test/V_files/。
我試圖通過下面提取文件名,但無法完成復制命令。
find -type f -iname "tmo*" -exec awk -F',' '$5 == "V" {print FILENAME}' {} \;
如何完成命令以復制具有第 5 列值為 V 的這些文件。
提前致謝
find 的-exec
可以用作過濾器:如果執行的程序返回零,則為“true”
find -type f -iname "tmo*" \
-exec awk -F, -v status=1 '$5 == "V" {status=0; exit} END {exit status}' {} \; \
-exec cp -vt /test/V_files {} +
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.