parsing - Ignoring directories from a file -
i in process of creating script lists files opened via lsof output. checksum specific files , ignore directories output @ loss effectively. example: (i'm using freebsd btw)
lsof | awk '/\//{print $9}' | sort -u | head -n 5
prints:
/ /bin/sleep /dev/bpf
what i'd is: output, ignore directories , perform md5 on files (not directories).
any pointers?
give try following perl
command:
lsof | perl -mdigest::md5=md5_hex -ane ' $f = $f[ $#f ]; -f $f , printf qq|%s %s\n|, $f, md5_hex( $f ) '
it filters lsof
output plain files (-f
). take perlfunc
change add different kind of files.
it outputs each file , md5
separated space character. example in system like:
/usr/lib/libm-2.17.so a2d3b2de9a1f59fb99427714fefb49ca /usr/lib/libdl-2.17.so d74d8ac16c2d13128964353d4be7061a /usr/lib/libnsl-2.17.so 34b6909ec60c337c21b044642b9baa3d /usr/lib/ld-2.17.so 3d0e7b5b5c4e59c5c4b6a858cc79fcf1 /usr/sbin/lsof b9b8fbc8f296e47969713f6369d97c0d /usr/lib/locale/locale-archive 3ea56273193198a718b9a5de33d553db /usr/lib/libc-2.17.so ba51eeb4025b7f5d7f400f1968f4b5f9 /usr/lib/ld-2.17.so 3d0e7b5b5c4e59c5c4b6a858cc79fcf1 ...
Comments
Post a Comment