Chinaunix首页 | 论坛 | 博客
  • 博客访问: 379451
  • 博文数量: 61
  • 博客积分: 4650
  • 博客等级: 上校
  • 技术积分: 786
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-11 21:07
个人简介

少抱怨,多实干;

文章分类

全部博文(61)

文章存档

2017年(1)

2016年(13)

2015年(1)

2013年(2)

2011年(1)

2010年(3)

2009年(23)

2008年(17)

我的朋友

分类: LINUX

2009-10-25 08:59:40

文件: 相应文件.zip
大小: 33KB
下载: 下载
一.按格式列出指定目录下的音乐
[ music]$ find ./like ./love1 ./love2 ./许巍 ./郑智化 -name "*[mMwW][pPmM][a3]" \
>-printf "%-20f %10k\n" | awk -F' ' 'BEGIN{i=0}{i=i+$NF/1024;for(j=1;j>printf("\t\t%5.2fM\n",$NF/1024"M")}END{printf("\n歌曲数目=%d首,总大小=%.2fM\n",NR,i)}

二.分类列出所有已经安装的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 :cs find c =expand("")
map :cs find d =expand("")
map :cs find f =expand("")
map :cs find g =expand("")
map :cs find i =expand("")
map :cs find s =expand("")
map :cs find t =expand("")
map :TlistToggle

"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

阅读(1748) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~