• 30 Posts
  • 803 Comments
Joined 2 years ago
cake
Cake day: June 23rd, 2023

help-circle



  • You can do some wild shit with pipes:

    • head -10 /var/log/syslog - Look at the first ten lines of one of your log files, with timestamps on the front
    • cat /var/log/syslog | cut -d' ' -f1 - Splits the lines by a space delimiter (the -d' ' part), and grabs the first “field” (the one with the timestamp, using -f1)
    • cat /var/log/syslog | cut -d' ' -f1 | cut -dT -f1 - Splits the timestamp at the “T”, and leaves only the date
    • cat /var/log/syslog | cut -d' ' -f1 | cut -dT -f1 | sort | uniq -c - Gives you a count of each date
    • grep systemd /var/log/syslog | cut -d' ' -f1 | cut -dT -f1 | sort | uniq -c - For only the lines with ‘systemd’ on it, gives you a count of each date

    The standard GNU toolkit has a ton of utilities like that for doing stuff with text files.