Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
i need to do "read while" from a file and redirect teh output in different file.
may be these thing make it clear:
cat filo |while read file
cat $file | grep arch |cut -c37-68 >> testas filo contains name of some log files and i want:
cat filo
arch_backup_prdcma.101307_00:11:01
arch_backup_prdcma.101307_00:11:02
arch_backup_prdcma.101307_00:11:05
arch_backup_prdcma.101307_00:11:07cat arch_backup_prdcma.101307_00:11:01 > test1
cat arch_backup_prdcma.101307_00:11:02 >test2
and so on but i cant....?
any help??deepesh1081@gmail.com

i got what i was looking for . thanks for the workaround
!/bin/bash
#ls -l |grep 1013 |cut -c55-88 > filo
#ls -l |grep `date "+%m%d%y"` |cut -c55-88 > filo
ls -l |grep `date "+%m%d%y"` |cut -f 15 -d ' '> filo
rm test
export c=`wc -l filo |cut -c1`
cat filo |while read file
do
cat $file | grep arch |cut -c37-68 >> test
done
#ls -l |grep 1013 |cut -c55-88 > tilo
#ls -l |grep `date "+%m%d%y"` |cut -c55-88 > tilo
ls -l |grep `date "+%m%d%y"` |cut -f 15 -d ' ' > tilo
rm back
#export c=`wc -l tilo |cut -c1`
cat tilo |while read tile
do
export u=`cat $tile | grep arch|wc -l| cut -c8-9`
for ((i=0;i<$u;i++))
do
cat $tile|grep backup >>back
done
donepaste test back > back.out
sed 's, ,|,g' back.out > final.out
deepesh1081@gmail.com

here is the demo
this is the demo
sysadmins-computer-2:~/oracle> ll arch_backup_prdcm* ( the dir where
ur files are located)
-rw-r--r-- 1 dchaudha dchaudha 318 Nov 10 23:12
arch_backup_prdcma.101307_00:11:01
-rw-r--r-- 1 dchaudha dchaudha 222 Nov 6 15:44
arch_backup_prdcma.101307_00:11:02
-rw-r--r-- 1 dchaudha dchaudha 222 Nov 6 15:44
arch_backup_prdcma.101307_00:11:05
-rw-r--r-- 1 dchaudha dchaudha 222 Nov 6 15:44
arch_backup_prdcma.101307_00:11:07sysadmins-computer-2:~/oracle> cat arch* (content of all files)
archive log filename=/prdcma/arch01/arch_prdcma_2790_1_631629058.log
recid=2800 stamp=635850606
archive log filename=/prdcma/arch01/arch_prdcma_2795_1_631629054.log
recid=2800 stamp=635850608
archive log filename=/prdcma/arch01/arch_prdcma_2796_1_631629054.log
recid=2801 stamp=635850617
Finished backup at 14-OCT-07archive log filename=/prdcma/arch01/arch_prdcma_2767_1_631629055.log
recid=2800 stamp=635850608
archive log filename=/prdcma/arch01/arch_prdcma_2768_1_631629055.log
recid=2801 stamp=635850617
Finished backup at 10-OCT-07archive log filename=/prdcma/arch01/arch_prdcma_2797_1_631629055.log
recid=2800 stamp=635850608
archive log filename=/prdcma/arch01/arch_prdcma_2798_1_631629055.log
recid=2801 stamp=635850617
Finished backup at 13-OCT-07archive log filename=/prdcma/arch01/arch_prdcma_2695_1_631629054.log
recid=2800 stamp=635850608
archive log filename=/prdcma/arch01/arch_prdcma_2696_1_631629054.log
recid=2801 stamp=635850617
Finished backup at 19-OCT-07
sysadmins-computer-2:~/oracle> ./finalsysadmins-computer-2:~/oracle> cat final.out
arch_prdcma_2790_1_631629058.log|Finished backup at 14-OCT-07
arch_prdcma_2795_1_631629054.log|Finished backup at 14-OCT-07
arch_prdcma_2796_1_631629054.log|Finished backup at 14-OCT-07
arch_prdcma_2767_1_631629055.log|Finished backup at 10-OCT-07
arch_prdcma_2768_1_631629055.log|Finished backup at 10-OCT-07
arch_prdcma_2797_1_631629055.log|Finished backup at 13-OCT-07
arch_prdcma_2798_1_631629055.log|Finished backup at 13-OCT-07
arch_prdcma_2695_1_631629054.log|Finished backup at 19-OCT-07
arch_prdcma_2696_1_631629054.log|Finished backup at 19-OCT-07
sysadmins-computer-2:~/oracle>
and the final scriptsysadmins-computer-2:~/oracle> cat final
#!/bin/bash
ls -l |grep 1013 |cut -c55-88 > filo #### check the output of
the command####
rm test
export c=`wc -l filo |cut -c1`
cat filo |while read file
do
cat $file | grep arch |cut -c37-68 >> test
done
ls -l |grep 1013 |cut -c55-88 > tilo
rm back
#export c=`wc -l tilo |cut -c1`
cat tilo |while read tile
do
export u=`cat $tile | grep arch|wc -l| cut -c8-9`
for ((i=0;i<$u;i++))
do
cat $tile|grep backup >>back
done
donepaste test back > back.out
sed 's, ,|,g' back.out > final.out
####################end##################sysadmins-computer-2:~/oracle> ls -l |grep 1013 |cut -c55-88 ( as
spacing matter so just varify)
arch_backup_prdcma.101307_00:11:01
arch_backup_prdcma.101307_00:11:02
arch_backup_prdcma.101307_00:11:05
arch_backup_prdcma.101307_00:11:07
deepesh1081@gmail.com

![]() |
ubuntu issues with dual b...
|
unable to mount Linux/SUS...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |