【发布时间】:2016-11-27 10:49:24
【问题描述】:
我知道还有一些其他类似主题的问题。但是解决方案对我不起作用。以下代码应比较两个 .csv 文件的时间戳。但是比较不起作用。
#!/bin/bash
input1="/home/seconion/Desktop/DatasetAnalyse/BYOD/alertTimeConverted.csv"
input2="/home/seconion/Desktop/DatasetAnalyse/BYOD/gt_byodTimeConverted.csv"
while IFS=',' read -r timestamp1 msg1 proto1 srcIP1 srcPort1 dstIP1 dstPort1
do
echo "next alert"
while IFS=',' read -r timestamp21 timestamp22 duration2 proto2 srcIP2 srcPort2 dstIP2 dstPort2 iflags2 uflags2 riflags2 ruflags2 pkt2 rpkt2 oct2 roct2 app2 entropy2 rentropy2 label2 category12 category22 comments2
do
alertTime=$(date -d "$timestamp1" +"%H%M%S%N")
streamTimeStart=$(date -d "$timestamp21" +"%H%M%S%N")
streamTimeEnd=$(date -d "$timestamp22" +"%H%M%S%N")
if [ $streamTimeStart -lt $alertTime ] && [ $alertTime -lt $streamTimeEnd ];
then echo "true"
fi
done < "$input2"
done < "$input1"
【问题讨论】:
-
您能否告诉我们
streamTimeStart、streamTimeEnd和alertTime的一些示例值? -
这是格式:223445248591000
-
你用的是
GNU date,能查一下date --version吗? -
它的 GNU coreutils 8.21
-
在您的问题中添加来自
$timestamp1、$timestamp21和$timestamp22的真实示例。