Recent Changes - Search:

Bob Brandt

Linux Projects


Server Projects

Desktop Projects

Novell Projects


VMware Projects


N900 (Maemo) Projects


Python Projects


OpenOffice.org Projects


Other Projects


PmWiki

edit SideBar

Useful Linux Scripts and Commands

Linux.MiniScripts History

Show minor edits - Show changes to markup

August 14, 2009, at 01:05 PM by 137.191.238.232 -
February 17, 2009, at 04:11 PM by 82.141.254.184 -
Changed lines 3-4 from:

Great SED Reference Site

to:

Great SED Reference Site

February 17, 2009, at 04:10 PM by 82.141.254.184 -
Added lines 3-4:

Great SED Reference Site

March 03, 2008, at 09:12 AM by 82.141.254.178 -
Added lines 149-155:

(:divend:)

How to Create an ISO File in Linux (:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:50px;":)

dd if=/dev/cdrom of=/cdrom_image.iso
January 17, 2008, at 01:23 PM by 82.141.254.184 -
Added lines 134-148:

(:divend:)

Monitor the /home drive and report if its usage is greater than 80%. (:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:75px;":)

#!/bin/bash

declare -i usage=0

usage=`df | grep "/home" | cut -c 52-54`
if [ $usage -gt 4 ]; then
	du --max-depth=1 /home | mail -s "Warning: Usage of /home is above 80 percent" "brandtb" 
fi
exit 0
December 05, 2007, at 03:41 PM by 82.141.254.184 -
Added lines 121-133:

(:divend:)

Find the fully qualified host name of a system (i.e. host.domain.name) (:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:75px;":)

function fullhostname {
domain=sed -n 's|^search\s\(.*\)|\1|p' /etc/resolv.conf | sed 's|\s.*||' | sed -n 's|\w\+\.\w\+|&|p'
if [ -n "$domain" ]; then
	domain=".$domain"
fi
echo `hostname`"$domain"
}
December 04, 2007, at 10:15 AM by 82.141.254.184 -
Changed line 107 from:

(:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:25px;":)

to:

(:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:75px;":)

Changed line 117 from:

(:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:50px;":)

to:

(:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:25px;":)

December 04, 2007, at 10:15 AM by 82.141.254.184 -
Changed line 117 from:

(:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:25px;":)

to:

(:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:50px;":)

December 04, 2007, at 10:15 AM by 82.141.254.184 -
Changed lines 109-112 from:
to:

function findpath() {

	relativepath=`echo "$0" | sed -n 's|\(.*\)/.*|\1|p'`
	pushd "$relativepath" > /dev/null ; pwd ; popd > /dev/null

}

Changed line 119 from:
to:

function findname() { echo $0 | sed 's|.*/||' }

December 04, 2007, at 10:11 AM by 82.141.254.184 -
Added lines 104-117:

(:divend:)

Find a full path from a relative path (:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:25px;":)


(:divend:)

Find the name of a script file (:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:25px;":)


November 04, 2007, at 09:30 PM by 217.75.11.25 -
Added lines 1-104:

(:title Useful Linux Scripts and Commands :)

Display a Hex dump of a file (:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:25px;":)

od -Ax -tx1z -v /path/to/filename

(:divend:)

Trim Strings (:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:100px;":)

# Front Trim
echo "   the test   " | sed 's/^[[:space:]]*//'

# Rear Trim
echo "   the test   " | sed 's/[[:space:]]*$//'

# Full Trim (the -e tells sed that there is more than one command)
echo "   the test   " | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'

(:divend:)

Find out how many specific characters there are in a string (i.e. how many t's are in a test string) (:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:60px;":)

char=t
numchar=`echo " the test string " | sed 's/[^$char]//g'`
numchar=${#numchar}

(:divend:)

Search and replace text within a file (:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:60px;":)

filename="$1"
searchtext="$2"
replacetext="$3"

sed 's~'"$searchtext"'~'"$replacetext"'~g' $filename

(:divend:)

Make sure user is root (:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:60px;":)

if [ "`id -u`" != "0" ]; then
	echo "You must be root to run this script" && exit 1
fi

(:divend:)

Ask for user input (:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:100px;":)

##############################################################################
# Below is the code responsible for producing asking a question              #
#                                                                            #
# USAGE:  userinput Question DefaultAnswer                                   #
#                                                                            #
##############################################################################
function userinput {
	echo -e -n "$1 [$2]: "
	read value
	if [ -z "$value" ]; then
		value=$2
	fi
	echo
}

(:divend:)

Script to find all the MAC Addresses Of Windows PCs in an IP subnet. (:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:250px;":)

#!/bin/bash

if [ "$1" == "" ]; then
	echo -e "Used to create a CSV file of all the IP Addresses in the a subnet and the MAC\n addresses of those Windows IPs" 2>&1
	echo -e "Usage: $0 aaa.bbb.ccc\n" 2>&1
	exit 1
fi

for i in `seq 1 254`
do

	ip="$1.$i"
	if ping -c 1 $ip > /dev/null
	then
		result=`nmblookup -A $ip | grep "MAC Address = "`
		if [ "$result" != "" ]; then
			echo "\"$ip\", \"$result\""
		fi
	fi
done
exit 0

(:divend:)

Edit - History - Print - Recent Changes - Search
Page last modified on August 14, 2009, at 01:05 PM