I have just spent the last several minutes googling and trying to see *how* that works.
I sort of understand ...but ..not really , not yet
so few lines
so elegant
I am sort of amazed.
You obviously have some skill - thank you
there 1 thing ...ideally we would find multiple line matches - more than 2 lines
these matches from the input text
if the below were zimbot.txt
Guangzhou_Yanyun_L_Bathroom_10_12_67594718.mp4
Guangzhou_Yanyun_L_Bathroom_13_30_67606173.mp4 < match 2 lines
Guangzhou_Yanyun_L_Bathroom_40_42_67607152.mp4 < no match
Guangzhou_Yanyun_L_Bathroom_50_60_67607152.mp4
Guangzhou_Yanyun_L_Bathroom_61_88_67607152.mp4
Guangzhou_Yanyun_L_Bathroom_89_90_67607152.mp4
Guangzhou_Yanyun_L_Bathroom_92_98_67607152.mp4 < a match of 4
Guangzhou_Yanyun_L_Bathroom_110_112_67607152.mp4 < no match
Guangzhou_Yanyun_L_Bathroom_120_130_67607152.mp4 < no match
Guangzhou_Yanyun_L_Bathroom_131_140_67607152.mp4
Guangzhou_Yanyun_L_Bathroom_141_150_67607152.mp4 < match 2 lines
Guangzhou_Yanyun_L_Bathroom_160_166_67607152.mp4
Guangzhou_Yanyun_L_Bathroom_167_168_67607152.mp4
Guangzhou_Yanyun_L_Bathroom_170_200_67607152.mp4 < a match of 3
so I have attempted to adapt your
#!/bin/bash
l1=1
lx=`awk "END {print NR}" list.txt` ## if the above 14 file.mp4 list were list.txt
file_num=1
while [ $l1 -lt $lx ]
do
l2=`expr $l1 + 1`
z1=`awk -F _ -v line=$l1 'NR==line {print $6}' list.txt`
z2=`awk -F _ -v line=$l2 'NR==line {print $5}' list.txt`
zx=`expr $z1 - $z2`
if [[ $zx -ge -5 ]] && [[ $zx -le 5 ]]
then
sed -n "$l1,$l2"p list.txt > $file_num.txt
((file_num++))
fi
((l1++))
done
I have been trying to adapt the above ( your good script ) to find these "multi" matches
but have not been successful
maybe it would be better in c ( or d or e
it is sooooo close