On 26/12/2023 16:51, Fred H Olson wrote:
I'm using the command:
head -n1
on all the 12,000+ text files in my system (!)
I have a few with CR line terminators (old Mac files?).
I used the command "file" to identify and make a list of text files
and created a long linear (12000+ lines) script that does something like:
head -n1 <filename1>
head -n1 <filename2>
etc
With this script, if a file has CR line terminators all of
the file is printed instead of just the first CR terminated line.
CR only terminators are increasingly rare as you said.
In the edge case of just caring about the first line,
you could convert CR to LF first. So any format txt file
could be handled with something like:
tr '\r' '\n' < "$filename" | head -n1
cheers,
Pádraig.