Skip to main content

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
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.
desired result::
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

code:
sed -e "s/.*[[:blank:]]\(.*-daemon.*:.*$\)/\1/g" -e "s/-daemon.*:/:/g" -e "s/:[[:blank:]]*\[.*\]/:/g" /tmp/junk
better wait bash guru comment


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk quick BASH(ish) question


Ubuntu

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support