$ cat /staging/SOI/dontran/don.txt
AASP.C0042.S0920.FUA01.CHG.LOG:AN:SNRPZFUA:OTA_CHANGE_LOG_FUA.txt
AASP.C0042.S0920.FUA01.CLIENT.OTA:AN:SNRPZFUA:OTA_MASTER_FUA.txt
SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL
$ ls -ltr *SNRPZFUA*
-rw-rw-r-- 1 ca7prod users 909351 Jun 8 08:21 AASP.C0042.S0920.FUA01.CHG.LOG:AN:SNRPZFUA:OTA_CHANGE_LOG_FUA.txt
-rw-rw-r-- 1 ca7prod users 29255450 Jun 8 08:21 AASP.C0042.S0920.FUA01.CLIENT.OTA:AN:SNRPZFUA:OTA_MASTER_FUA.txt
-rw-rw-r-- 1 ca7prod users 66980080 Jun 8 08:22 SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
-rw-rw-r-- 1 ca7prod users 269937540 Jun 8 08:22 SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
-rw-rw-r-- 1 ca7prod users 17920 Jun 8 08:22 SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
-rw-rw-r-- 1 ca7prod users 53760 Jun 8 08:23 SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL
This code work, but I like rename the filename output like below.
Quote:
#!/bin/ksh
cat /staging/SOI/dotran/don.txt | while read FILE
do
count=$(wc $FILE | awk '{print $1}')
echo "Filename: $FILE >> filename.txt
echo "RowCount: $count" >> filename.txt
done
|
cat filename.txt
Filename: AASP.C0042.S0920.FUA01.CHG.LOG:AN:SNRPZFUA:OTA_CHANGE_LOG_FUA.txt
RowCount: 4761
Filename: AASP.C0042.S0920.FUA01.CLIENT.OTA:AN:SNRPZFUA:OTA_MASTER_FUA.txt
RowCount: 167174
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
RowCount: 95960
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
RowCount: 386730
Filename: SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
RowCount: 40
Filename: SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL:AN:SNRPZFUA:SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL
RowCount: 120
This code not work. Please someone help help......please. The syntax not correct.
Quote:
#!/bin/ksh
cat /staging/SOI/dotran/don.txt | while read FILE
do
count=$(wc $FILE | awk '{print $1}')
#echo "Filename: `cat $FILE | cut -d: -f4`" >> filename.txt
echo "Filename: $FILE | `cut -d: -f4`" >> filename.txt
echo "RowCount: $count" >> filename.txt
#echo "Filename: $FILE\nRowCount: $count" >> /staging/SOI/dontran/file.txt
done
|
I like the out put should be like this: Thanks
cat filename.txt
Filename: OTA_MASTER_FUA.txt
RowCount: 167174
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE1
RowCount: 95960
Filename: SNRP.C0042.S0920.FUA01.OUTLET.FINAL.FILE2
RowCount: 386730
Filename: SNRP.C0042.S0920.FUA01.OUTLET1.NAT.ROLL
RowCount: 40
Filename: SNRP.C0042.S0920.FUA01.OUTLET2.NAT.ROLL
RowCount: 120