I want to display the first few line of each of a batch of log files, some of which are gzipped.
Normally I'd use zcat in place of cat, zgrep in place of grep, etc, to work with a mixture of compressed and uncompressed files. But zhead and ztail don't exist.
What's the best way to achieve this: zhead -n1 /var/log/syslog* (show the first line of each syslog* file)?
All the thoughts I had got increasingly convoluted. Obviously stuff like: zcat /var/log/syslog* | head -n1 .. doesn't achieve what I want...
All the thoughts I had got increasingly convoluted. Obviously stuff like: zcat /var/log/syslog* | head -n1 .. doesn't achieve what I want...
for a in /var/log/syslog*gz;do zcat $a 2>/dev/null|head -n 1;done
If you want to know which file the line came from:
for a in /var/log/syslog*gz;do echo "$a: $(zcat $a 2>/dev/null|head -n 1)";done
On 18 January 2013 13:06, Keith Edmunds kae@midnighthax.com wrote:
for a in /var/log/syslog*gz;do echo "$a: $(zcat $a 2>/dev/null|head -n 1)";done
Great, thanks! -- Mark Rogers // More Solutions Ltd (Peterborough Office) // 0844 251 1450 Registered in England (0456 0902) @ 13 Clarke Rd, Milton Keynes, MK1 1LG