Hello, i develop a shell unix program and i have a csv file. every time we have 5 identical lines in the first 3 columns in the fourth column can be different and the 5th too. In the 5th I have a date in yyyy / mm / dd. I want to do a sort on the 5 lines and keep only the line where there is the most recent date. Example for this particular file
[quote="excuse me but i did not understant very well the code can i explain me please.[/quote"]
Sure.
what?
#!/bin/sh
# Loop until we tell it to stop
while true
do
# Loop 5 times. Each loop reads and writes one line.
# We pipe it's output through sort, breaking fields on ; and
# sorting on the third field, and sort backwards.
# Then we throw away everything but the first line.
for N in 0 1 2 3 4
do
# Try to read a line. If it fails, quit.
read A || break
# Print the line.
echo "$A"
done | sort -r -t ';' -k 3 | head -n 1
# Read and ignore the lineful of dashes. quit if that fails.
read A || break
done < data