awk
2016-02-29 23:48
225 查看
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就退出。
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就退出。
相关文章推荐
- 程序员修炼之道:从小工到专家
- PHP之类特性
- 详解JDK 5 Annotation 注解之@Target的用法介绍
- TO-DO List
- poj2342&&hdu1520(树形dp)
- 进入新项目的注意事项
- 第12章 posix 线程
- String字符串
- Java8集合类库的批量数据操作
- Dragonboard 410C 之 开发板设计规范
- Kobject、Kset 和 Subsystem
- Unable to load configuration. - action(spring + strut2 整合)
- 接口的意义
- 学习不经常用的知识点要做笔记
- JVM内核解读
- 在Raspberry Pi上安装Archlinux arm的问题解决
- 第一章 对象导论
- JVM初篇
- elasticsearch扩容和机器下线
- smarty模板