It then uses the exec command to run a command on every match found,
it could easily be rm to remove files instead of listing them.
find /home/ -type f -mtime +3 -exec ls -l {} \;
find /home/ -type f -mtime +3 -exec ls -l {} \;
#Need to add read lines for $1 - $6 user input
date_proc () # MM dd hh mm ss yy ¦#
# dialogue param order # 2 3 4 5 6 1 ¦#
{
yy=$1
MM=$2
dd=$3
hh=$4
mm=$5
ss=$6
yy=${yy##*(0)}
yy=${yy##*(0)}
MM=${MM##*(0)}
dd=${dd##*(0)}
hh=${hh##*(0)}
mm=${mm##*(0)}
ss=${ss##*(0)}
DATE_STR=`/usr/bin/printf \"%02d%02d%02d%02d.%02d%02d\" $(($MM)) $(($dd)
) $(($hh)) $(($mm)) $(($ss)) $(($yy))`
/usr/bin/date \"$DATE_STR\"
}
date_proc \'08\' \'11\' \'05\' \'14\' \'01\' \'00\'
#!/bin/bashDATE=`date +%H%M-%d%m%y`
TWPRINT="/opt/tripwire/sbin/twprint -m r -r"
TWREPORT=/opt/tripwire/reports
TWHOSTNAME=`hostname`.twr
TWASCII=/tmp/${TWHOSTNAME}.txt
COMP_DIR=${TWREPORT}/COMPRESSED
TWLOG=/tmp/tripwire.tmp
MAILSUB="${HOSTNAME} Report ${DATE}"
get_ascii_report(){
${TWPRINT} ${TWREPORT}/${TWHOSTNAME} > ${TWASCII}
}section(){
cat ${TWASCII} | sed -n "/$1/,/$2/p" >> ${TWLOG}
echo " " >> ${TWLOG}
}cleanup(){
if [ -f ${TWLOG} ]
then
rm -f ${TWLOG}
fi
# Remove fies older than 1 month
find ${COMP_DIR} -type f -mtime +31 -exec rm {} \; 2>/dev/null
}compress_logs(){
testdir ${COMP_DIR}
gzip -c ${TWASCII} > ${COMP_DIR}/${TWHOSTNAME}.${DATE}.gzip 2>/dev/null
}testdir(){
if [ ! -d ${1}/ ]
then
mkdir ${COMP_DIR}
fi
}header(){
echo "Tripwire Report for ${DATE}." >> ${TWLOG}
echo " " >> ${TWLOG}
echo "Please ensure you have checked the report for Errors." >> ${TWLOG}
echo "Also ensure the report is checked for any Severity levels higher
than 0." >> ${TWLOG}
echo "The Full Report can be found at" ${TWASCII} >> ${TWLOG}
echo "Use # zcat ${COMP_DIR}/${TWHOSTNAME}.${DATE}.gzip to view log."
>> ${TWLOG}
echo " " >> ${TWLOG}
}mailto(){
MAILSUB="Tripwire Report for ${HOSTNAME} ${DATE}"
RECP=paul.ward@datacom.co.nz
mail -s "${MAILSUB}" ${RECP} < ${TWLOG}
}# Script begins
cleanupget_ascii_report
header
echo "Rule Name Severity Level Added
Removed Modified" >> ${TWLOG}
section "Tripwire Data Files" "Total violations found:"
section "Error Report:" "End of report"
compress_logs
mailto
cat filename.txt | sed -n "/^first line to to cut/,/last lne to cut/p"| sed '$d'
sed -n \"/^Rule Summary:/,/^Total violations found:/p\"
#!/bin/sh
array=(jerry gen glan rahim)
len=${#array[*]} #Number of elements of the array
echo \"The array has $len members. They are:\"
i=0
while [ $i -lt $len ]; do
echo \"$i: ${array[$i]}\"
let i++
done
#Some operations
echo \"Adding \"jack\" to the end of the array\"
array=( \"${array[@]}\" \"jack\" )
echo \"Listng all the elements in the array\"
echo \"${array[@]}\"
echo \"Listng all the elements in the array\"
echo \"${array[*]}\" #One more way
echo \"Deleting \\\"gen\\\"\"
unset array[1] #Same as array[1]=
echo \"Now the array is\"
echo \"${array[@]}\"
echo \"length of 3rd element in the array\"
len1=${#array[2]}; echo $len
echo \"Deleting the whole array\"
unset array
echo \"${array[@]}\" #Array is empty
This code does just that.
# awk 'NR==$line{print;exit}' $filename