awk

http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858470.html


tt.log文件内容
         14 1048576000 /usr/oracle/data/PRD0.2/store_ix10.dbf   INDICES
         14  367001600 /usr/oracle/data/PRD0.2/store_ix11.dbf   INDICES
         14 1258291200 /usr/oracle/data/PRD0.3/store_new.dbf    STORE_NEW
         18 1048576000 /usr/oracle/data/PRD0.2/store_ix10.dbf   INDICES
         18  367001600 /usr/oracle/data/PRD0.2/store_ix11.dbf   INDICES
         18  157286400 /usr/oracle/data/PRD0.2/store_ix12.dbf   INDICES

我想从tt.log文件中取出1,3列来执行rexec命令
写了ta.sh执行文件,内容如下
while read t1 t2 t3 t4
do
echo $t2 $t4
rexec lshas$t1 "ls -lt $t3|awk '{print $5,$9}' "
done <tt.log

为什么执行的时候,只执行第一行啊,我看了执行顺序如下
+ 0< tt.log
+ read t1 t2 t3 t4
+ echo 1048576000 INDICES
1048576000 INDICES
+ rexec lshas10 ls -lt /usr/oracle/data/PRD0.2/store_ix10.dbf|awk '{print $5,$9}'
1048580096 /usr/oracle/data/PRD0.2/store_ix10.dbf
+ read t1 t2 t3 t4

不读第二行,请高手指教。



我修改了一下:我用了个for 循环了
node=`awk '{print $1}' /root/node`
for a in $node ; do
不用while的方式
那种方式的问题可能是读文件的时候读完第一行就认为已经结束,while就退出。

原文地址:https://www.cnblogs.com/double12gzh/p/10166198.html