日期:2014-05-16  浏览次数:20584 次

请教linux 脚本操作
A目录:
20111210-13.txt
B目录:
...
20111210-11.txt
20111210-12.txt
20111210-13.txt
20111210-14.txt
20111210-15.txt
...
有什么方法通过A目录下的-13文档,匹配B目录20111210-13.txt,并打印及其以后的文档(即13,14,15...)出来;

说明,B目录文档可能不按以上例子顺序,不过最终结果都是(13,14,15...)

------解决方案--------------------
大概试了下好像可以,你试试看,不行再改改。

Assembly code

#!/bin/bash
for i in `ls /tmp/log`
do
#echo $i
ds=`ls /tmp`
ds2=`echo $ds|grep "$i"`
if [ "$ds2" != "" ]
then
#echo $ds2
echo $i ${ds#*$i}
fi
#${ds/*$i/$i} && echo $result || echo '' 
done

------解决方案--------------------
Assembly code
fileA=`ls ./a`
ls -1 ./b | sed -n "/$fileA/,\$p"