shell痕迹

上一篇 / 下一篇  2007-12-21 21:24:31 / 个人分类:linux学习

1. 读键盘输入

echo -n "input your merge file(full path):"
read mergefile

2. 读文件

while read LINE
do
    xxxx
done <  $mergefile

3. 对多行的输出截取替换等

cat xxx | tail -n 2 |head -1 |awk '{print $1}'|sed -e 's/r//g'`

4. 字符串按特定字符截位

while [ -z $stat ]; do
 pos=`expr index $select ","`
 if [ $pos -eq 0 ]; then
  subselect=$select
  select=
  stat='ok'
 else
  subselect=`echo ${select:0:$pos - 1}`
  select=`echo ${select:$pos}`
 fi
 echo $select
 echo $subselect
done

 


TAG: linux学习

 

评分:0

我来说两句

日历

« 2024-05-13  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 5756
  • 日志数: 8
  • 建立时间: 2007-12-21
  • 更新时间: 2008-05-26

RSS订阅

Open Toolbar