![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using File Descriptors, traverse a list | MaestroRage | UNIX for Dummies Questions & Answers | 2 | 02-12-2008 07:05 PM |
| Traverse catalogs | baghera | Shell Programming and Scripting | 3 | 08-30-2007 09:29 AM |
| Traverse Directory Tree for backup | srmadab | Shell Programming and Scripting | 1 | 09-11-2006 06:16 PM |
| Check this out. Find out the errors as much as possible. thanks | CULM | What's on Your Mind? | 6 | 11-11-2005 03:43 AM |
| Check my crontab for possible errors. | yongho | UNIX for Dummies Questions & Answers | 4 | 06-20-2005 03:27 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi,
I need to check a flatfile for various parameters like length of the record, format of record, any tab character present in the record etc., for checking presence of tab character, i'm trying to use the following code and i'm not sure if the same is right. Pls Help. Code:
nawk '{print length($0)}' $fdate > filelength.txt
totrec=`cat filelength.txt | wc -l`
i=1
while [ $i -le $totrec ]
if [ $i -gt 1 ] && [ $i -lt $totrec ]; then
if [ D -eq `nawk "(NR==${i}){print}" $fdate | cut -b1` ]; then
if [ `nawk "(NR==${i}){print}" filelength.txt` -eq 3168 ]; then
tabrec=`nawk '/[\t]/ {if (NR==\$i) {print $0} }' $fdate`
echo $tabrec
if [ `nawk '/[\t]/ {if (NR==\$i) {print NR} else {print 0} }' $fdate` ]; then
echo "The Detail record $i has a tab character inside it"
nawk "(NR==${i}){print} $fdate" >> ./error/$fdate.err
else
echo "The Detail record $i looks fine"
nawk "(NR==${i}){print} $fdate" >> ./output/$fdate.dat
fi
else
echo "The Detail record $i length is not proper"
nawk "(NR==${i}){print} $fdate" >> ./error/$fdate.err
fi
else
echo "The Detail record $i format is not proper"
nawk "(NR==${i}){print} $fdate" >> ./error/$fdate.err
fi
fi
i=`expr $i + 1`
done
Thanks in Advance. Regards, Aravind. C Last edited by aravindc; 04-17-2008 at 03:03 AM.. Reason: Meaningful subjectline |
|
||||
|
First take a look at Useless Use of Cat and corect your script, second use code tag.
Note: You can edit your original post. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|