少抱怨,多实干;
分类: LINUX
2009-10-25 08:59:40
|
二.分类列出所有已经安装的rpm包
#!/bin/sh
red=$(echo -e '\033[1;31;40m')
green=$(echo -e '\033[1;32;40m')
white=$(echo -e '\033[1;37;40m')
#-t fd, 1:stdout
if ! [ -t 1 ] ;then
red=
green=
white=
fi
rpm -qa --qf '%{group}\n' | sort | uniq | while read rpm_group
do
echo "$red$rpm_group$white:"
#Assume:
#(1) %{name}-%{version} contains no spaces
#(2) strlen(%{name}-%{version} <= 30
rpm -q --qf "%{name}-%{version}%{summary}\n" --group "$rpm_group" | \
green="$green" white="$white" awk '{printf "%s%-30s%s:%s\n",ENVIRON["green"],$1,ENVIRON["white"],substr($0,length($1)+2);}' |\
sed 's/^/ /'
done
三.自动挂载嵌入式设备中的U盘,让守护进程来定时调用(不够好)
#!/bin/sh
#
# place you want to mounted
#
MOUNTDIR=/mnt
#
# dev's place
#
#AIMDIR=/dev/scsi
AIMDIR=/home/usbtest/scsi
#
# dev's name
#
TARGETDEV=part1
TMPDIR=${AIMDIR}
#USBLOGFILE=/etc/usb.log
USBLOGFILE=/home/usbtest/usb.log
#DEBUGFILE=/home/usbtest/log
cd ${AIMDIR}
# use while to find the dir(full path) where the part should be existence
while [ "${TMPDIR}" ]
do
echo tmpdir=${TMPDIR}
cd ${AIMDIR}
TMPDIR="`ls -l | grep '^d' | tail -n 1 | awk -F' ' '{print $8}'`"
if [ "${TMPDIR}" ]
then
AIMDIR=${AIMDIR}/${TMPDIR};
fi
done
#######################################
#echo "AIMDIR = ${AIMDIR}" >>${DEBUGFILE}
##########################################
AIMFILE=`ls | grep $TARGETDEV`
if [ ! "${AIMFILE}" ] || [ ! "${AIMFILE}" ]
then
cat /dev/null > ${USBLOGFILE}
exit 1
fi
##########################################
AIMFILE=${AIMDIR}/${AIMFILE}
if [ -f "${USBLOGFILE}" ]
then
PREFILE=`cat ${USBLOGFILE}`
else
PREFILE=
fi
if [ "${PREFILE}" != "${AIMFILE}" ]
then
#mount ${AIMFILE} ${MOUNTDIR}
echo "`date` usb mounted on ${AIMFILE}" >> ${DEBUGFILE}
echo ${AIMFILE} > ${USBLOGFILE}
else
cat /dev/null > ${USBLOGFILE}
fi
#####################################################
#echo "AIMFILE = ${AIMFILE}" >> ${DEBUGFILE}
#echo "PREFILE = ${PREFILE}" >> ${DEBUGFILE}
#echo "MOUNTIDR = ${MOUNTDIR}" >> ${DEBUGFILE}
######################################################
exit 0
四. 我的vim的配置
let Tlist_Show_One_File=1
"set autochdir
set tag=tags
map
map
map
map
map
map
map
map
"set cscopequickfix=s-,c-,d-,i-,t-,e-,f-
colo console
set guioptions-=m "Remove menubar
set guioptions-=T "Remove toolbar
set guioptions-=r "Remove v_scroolbar"
set ai
set tabstop=4
set syntax=on
set ff=unix
set number
set autoindent
set nocompatible " Use Vim defaults (much better!)
set bs=indent,eol,start " allow backspacing over everything in insert mode
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
" than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time