我有超過100個列和行1000+(myfile.csv)csv文件,我需要打印頭和每行與小區值小於0.2在至少一個柱(無論哪一列的)到一個新文件(newfile_0.2.csv)。我確實需要整行。如何與比任何列的0.2小的單元格的值顯示的行?
我只能找到這樣做了specific column的方式。
這是我的嘗試失敗的列表(我是很新的編碼):
awk '(NR==1) || ($0 < 0.2) ' myfile.csv > newfile_0.2.csv
awk -F "," 'BEGIN $0 < 0.2 {print $0}' myfile.csv > newfile_0.2.csv
awk -F "," '{OFS = ","} BEGIN {$0 < 0.2} {print $0}' myfile.csv > newfile_0.2.csv
awk '{FS = ","} {OFS = ","} BEGIN {$0 < 0.2} {print $0}' myfile.csv > newfile_0.2.csv
awk -F "," '{if ($0 < 0.2) print $0}' myfile.csv > newfile_0.2.csv
while read line; do awk -F "," '{if ($0 < 0.2) print $0}' line ; done <myfile.csv> newfile_0.2.csv
while read line; do echo $line | awk -F "," '{for (i=1;i<=NF;i++) if ($i < 0.2) print $i}'; done <myfile.csv> newfile_0.2.csv
會有人知道如何做到這一點?謝謝!
整個行可能與'$ 0'訪問。 – Scheff