Show procfiles

Aus Si:Wiki von Siegrist SystemLösungen - Informatik und Rezepte
Zur Navigation springen Zur Suche springen
Dieses Programm ist lediglich eine Vorlage, für eine bestimmte Version einer bestimmten Distribution.
Für alle anderen Versionen und Distributionen bitte etwas anpassen.
Extrem hilfreich um irgendwas irgendwo im /proc zu finden.


Man beachte das: "... | -h | --help ]"; ist das nicht schön und es tut überhaupt nicht weh.


#!/bin/bash

WITHOUT_THIS_FILES="pagemap kmsg kcore kpageflags kpagecount kallsyms"

if [[ $1 == "-h" || $1 == "--help" ]] ; then
	echo -e "Show nearly all readable files on /proc filesystem to stdout except the PID directories. Use -P to include PID directories.\nA given <search-pattern> turns you into 'less' and start at the first occurrence of them." 
	echo -e "\nusage: `basename $0` [ [-P] [<search-pattern>] | -h | --help ]"
	exit
fi

UPF="-regextype emacs \! -regex .\/[0-9].*"
[[ $1 = "-P" ]] && UPF="" && shift

for f in $WITHOUT_THIS_FILES ; do
	WTF="$WTF \! -name $f"
done

[[ -n $1 ]] && PAT=" | /usr/bin/less -i -p $1"

cd "/proc"

eval "find -P . $UPF -type f $WTF -print -exec cat \{\} \; 2>/dev/null | sed -e 's/^\.\//\\n-------------------------------------------------------\.\//' 2>/dev/null $PAT"

cd $OLDPWD