script to extract system details and produce CSV file


#!/bin/bash
LOG=/home/john/bin/test-out-results-final.txt
cat /dev/null > $LOG
# find total file types by owners in sbin, etc, usr, var
# create output file in CSV format:  dir, owner, type, qty.  		ASSUME -f and -d file types
# users: # sbin - root # etc - root # usr - root abrt
# var: abrt apache daemon foo games gdm john lp ntp pulse root rpc rpcuser smmsp thedefault torrent
#########################
ls -alR /sbin | awk '{print $3}'| sort | uniq | grep -v ^$ |  tee users-of-sbin
ls -alR /etc | awk '{print $3}' | sort | uniq | grep -v ^$ |  tee users-of-etc
ls -alR /usr | awk '{print $3}' | sort | uniq | grep -v ^$ |  tee users-of-usr
ls -alR /var | awk '{print $3}' | sort | uniq | grep -v ^$ |  tee users-of-var
#########################
echo "--------------------------------------------------" # these echos are for readability ONLY
for x in `cat users-of-sbin`
	do
	echo "sbin" | tee -a $LOG
	echo $x | tee -a $LOG
	echo "plain" | tee -a $LOG
	find /sbin -type f -user $x -print | wc -l | tee -a $LOG
echo "--------------------------------------------------"
	echo "sbin"| tee -a $LOG
	echo $x | tee -a $LOG
	echo "dir" | tee -a $LOG
	find /sbin -type d -user $x -print | wc -l | tee -a $LOG
	done
echo "--------------------------------------------------" # these echos are for readability ONLY
for x in `cat users-of-etc`
	do
	echo "etc" | tee -a $LOG
	echo $x | tee -a $LOG
	echo "plain" | tee -a $LOG
	find /etc -type f -user $x -print | wc -l | tee -a $LOG
echo "--------------------------------------------------"
	echo "etc"| tee -a $LOG
	echo $x | tee -a $LOG
	echo "dir" | tee -a $LOG
	find /etc -type d -user $x -print | wc -l | tee -a $LOG
	done
echo "--------------------------------------------------"
for x in `cat users-of-usr`
	do
	echo "usr" | tee -a $LOG
	echo $x | tee -a $LOG
	echo "plain" | tee -a $LOG
	find /usr -type f -user $x -print | wc -l | tee -a $LOG
echo "--------------------------------------------------"
	echo "usr"| tee -a $LOG
	echo $x | tee -a $LOG
	echo "dir" | tee -a $LOG
	find /usr -type d -user $x -print | wc -l | tee -a $LOG
	done
echo "--------------------------------------------------"
for x in `cat users-of-var`
 	do
 	echo "var" | tee -a $LOG
 	echo $x | tee -a $LOG
 	echo "plain" | tee -a $LOG
 	find /var -type f -user $x -print | wc -l | tee -a $LOG
echo "--------------------------------------------------"
 	echo "var" | tee -a $LOG
 	echo $x | tee -a $LOG
  	echo "dir" | tee -a $LOG
 	find /var -type d -user $x -print | wc -l | tee -a $LOG
 	done
echo "--------------------------------------------------"
# perl -pe 's/\n/,/ if(++$i%4&&! eof)' raw-output.txt
cp $LOG /home/john/LAB_10/copy-of-output.tmp
perl -pe 's/\n/,/ if(++$i%4&&! eof)' $LOG | tee CSV-lab-10-1.csv
echo "--------------------------------------------------"


ebook:
Full Size
Jeep Buyer's
Guide
ebook:
Practical Suggestions
for Microsoft
Windows
Linux Tackles Microsoft
12 hour Video Course by john:
The Art of Linux System Administration
published by O'Reilly Media
Study Guide for the LPIC-2 Certification Exams
search for:
on the internet, or:
JohnMeister.com-fotos
LinuxMeister-Linux
BibleTech-
Bible overview


An overview of Biblical history:
"Promises and Prophets"

Wagoneers

FULL SIZE JEEPS

JeepMeister
"Jeep is America's
only real sports car."
-Enzo Ferrari


MeisterTech
Diesels +

One Page Overview of Linux Commands

click for an image of the 5 essential Linux commands

An Intro to Linux
AMSOIL product guide,
or, AMSOIL web, or 1-800-956-5695,
use customer #283461

Amsoil dealer since 1983
purchase AMSOIL
at Midway Auto on SR9 in Snohomish,
or at Northland Diesel in Bellingham, WA


SJ - 1962-1991

XJ - 1984-2001

WJ - 1999-2004

KJ - 2002-2007

WK - 2005-2010

Find the recommended
AMSOIL synthetics
for your Jeep

CJ-10A - 1984-1986

Jeepsters

MJ - 1984-1992

Willys - 1946-1965

Other Jeeps (FC)