Удалить все строки в CSV-файле без соответствующих/совпадающих временных меток в другом CSV-файле

Пробовал со скриптом «Ниже», тоже работало нормально

Пожалуйста, запустите скрипт после 12:00

#!/bin/bash
d=`date +%Y-%m-%d -d "1 days ago"`
#echo $d
echo "Below are list of files present"
find . -maxdepth 1 -type f -iname "*.txt" -newermt $d| sed "s/\.\///g"

count=`find . -maxdepth 1 -type f -iname "*.txt" -newermt $d| sed "s/\.\///g"| wc -l`
if [ $count -eq 9 ]
then
echo "Total Number of file exsists in present directory is $count"
zero_sizefile=`find . -maxdepth 1 -type f -iname "*.txt" -newermt $d -size 0| wc -l`
if [ $zero_sizefile > 0 ]
then
echo "Below are zero sized files"
find . -type f -iname "*.txt" -newermt $d -size 0
else
echo "No files are zero sized files"
fi
else
echo "All files doesnt exists"
fi
0
26.11.2020, 12:40
2 ответа

Вот так:

$ awk -F, 'NR==FNR {a[$5 FS $6]; next} ($1 FS $2) in a' file1 file2  
date,time,col3
2019-07-20,12:40:00,1
2019-07-20,12:43:00,4
2019-07-20,12:44:00,5
2019-07-20,12:45:00,6
2019-07-20,12:46:00,7
2019-07-20,12:47:00,8
4
18.03.2021, 22:47
csv-sqlite -i file1.csv -i file2.csv \
  'select * from input2 where date || time in (select date || time from input1) |
  csv-header --remove-types'

csv -sqlite взят из csv -nix -tools .

0
18.03.2021, 22:47

Теги

Похожие вопросы