Thread: quick BASH(ish) question
at day job, spend of time reading through long, tedious, timestamped, log-looking files, part of real concern last few words of line. trying write script that, given text-only input file, rid of (largely) unimportant junk @ beginning, , leave behind easier read version in seperate file.
have of script figured out, hung on 1 thing- cannot think of command, or string of commands, either delete leading (pattern-following) text on line or select last group of words (non-pattern-following) , move new file.
ideas?
************************************************
example- (not actual usage)
sample input
desired result::code:jun 13 09:51:16 mxx0200gtp-hp-pc dbus-daemon: [system] reloaded configuration jun 13 09:51:23 mxx0200gtp-hp-pc dbus-daemon: [system] reloaded configuration jun 13 19:41:12 mxx0200gtp-hp-pc avahi-daemon[609]: found user 'avahi' (uid 104) , group 'avahi' (gid 109). jun 13 19:41:12 mxx0200gtp-hp-pc avahi-daemon[609]: dropped root privileges. jun 13 19:41:12 mxx0200gtp-hp-pc avahi-daemon[609]: avahi-daemon 0.6.27 starting up. jun 13 19:41:12 mxx0200gtp-hp-pc avahi-daemon[609]: called chroot(). jun 13 19:41:12 mxx0200gtp-hp-pc avahi-daemon[609]: dropped remaining capabilities. jun 13 19:41:12 mxx0200gtp-hp-pc avahi-daemon[609]: no service file found in /etc/avahi/services.code:dbus: reloaded configuration dbus: reloaded configuration avahi: found user 'avahi' (uid 104) , group 'avahi' (gid 109). avahi: dropped root privileges. avahi: avahi-daemon 0.6.27 starting up. avahi: called chroot(). avahi: dropped remaining capabilities. avahi: no service file found in /etc/avahi/services.
lol !! came code, haven't checked if works on possible inputs, works 1 atleast
assuming logs in file /tmp/junk
better wait bash guru commentcode:sed -e "s/.*[[:blank:]]\(.*-daemon.*:.*$\)/\1/g" -e "s/-daemon.*:/:/g" -e "s/:[[:blank:]]*\[.*\]/:/g" /tmp/junk![]()
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk quick BASH(ish) question
Ubuntu
Comments
Post a Comment