The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-17-2008
aravindc aravindc is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 2
Unhappy Check records for errors

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
I check for Record to start with 'D' and total record length to be equal to 3168 and if tab is present in the record.

Thanks in Advance.

Regards,
Aravind. C

Last edited by aravindc; 04-17-2008 at 03:03 AM.. Reason: Meaningful subjectline
  #2 (permalink)  
Old 04-17-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,420
First take a look at Useless Use of Cat and corect your script, second use code tag.
Note: You can edit your original post.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0