Computing.Net > Forums > Unix > script with word count compare

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

script with word count compare

Reply to Message Icon

Name: Bobbi
Date: August 24, 2002 at 07:35:37 Pacific
Comment:

Still can't get this to work:
This is what I am trying to do

1) The fist file I am looking for is in this directory:
xnet-stc/int/exe_inbound/history
(There will always be a file)
The search term would be exe_act*.dat with the current days timestamp only.
Otherwise it will pick up all the exe_act* files in the history directory.
I do a word count on it to get the number of lines only and put that into a variable.


2) The next 3 files are in the directory
stc-sap/int/exe_inbound
so I need to change the path(which is not a problem so far)

3) Then I need to do a word count for number of lines only on
exe_gr*.tmp
exe_rtv*.tmp
exe_invadj*.tmp
and put those into variables(or one variable?)

********The problem here is there are days when not all three files will be there so I
need to do a find first I guess and return a count of zero, or return nothing if the
file is not there. (initialize to zero?)*********

Then I need to add the wordcount from the 3 files(or1 or 2, whatever is there) and put into
a variable(or whatever is easiest)

Then I need to compare the wc in the variables from step 1 and step 3.
If they match, exit and end.

If they do not match:

delete
exe_gr*.tmp
exe_rtv*.tmp
exe_invadj*.tmp
(that is ok since I am in that directory still)

Then I would need to move up to xnet-stc/int/exe_inbound/history
and somehow take the exe-act*.dat file that I did the wordcount on and
move it up one directory to xnet-stc/int/exe_inbound and rename the file
extension from .dat to .tmp
Then exit and end

I seem to be having a problem with the move
I can get it to delete the other files but that's it!

Can anyone help? I thought this would be simple for me but I guess I am such a beginner that it is making me crazy!
Thank in advance



Sponsored Link
Ads by Google

Response Number 1
Name: yomama
Date: August 25, 2002 at 09:52:55 Pacific
Reply:

include your script


0

Response Number 2
Name: Bobbi
Date: August 26, 2002 at 12:15:35 Pacific
Reply:

cd xnet-stc/int/exe_inbound/history
echo "Displaying list of activity files for DC4"

TEST=`find exe_act_0004* -mtime -1`
echo $TEST

read ANS?
ACT=`wc $TEST | cut -c7-12`
echo $ACT

echo "==========================="

cd
cd stc-sap/int/exe_inbound/

echo "Displaying Word Count for Goods Receipt File"
wc exe_gr*.tmp

echo "Displaying Word Count for RTV File"
wc exe_rtv*.tmp

echo "Displaying Word Count for Inventory Adjustment File"
wc exe_invadj*.tmp
read ANS?

GR=`wc exe_gr*.tmp | cut -c5-11`
echo $GR

RTV=`wc exe_rtv*.tmp | cut -c5-11`
echo $RTV

INV=`wc exe_invadj*.tmp | cut -c5-11`
echo $INV

let A=GR+RTV+INV
echo "============================================="
echo $A


echo "Do the files sizes match?"
read A ACT

if [ A = ACT ]

then
echo "Yes,the file sizes match"
#exit 0

elif [ A != ACT ]
then
echo "No, the file sizes don't match."
echo "Do you wish to re-process?"

echo "Input y for yes or n for no:\c"
read answer
if [ answer=Y ]
then
rm exe_gr*.tmp
rm exe_rtv*.tmp
rm exe_invadj*.tmp
cd
cd xnet-stc/int/exe_inbound/history
mv $TEST .. /exe_act_0004.tmp
else
echo "Goodbye"
#exit 0
#fi
fi
fi



0

Response Number 3
Name: Bobbi
Date: August 27, 2002 at 16:49:31 Pacific
Reply:

Can someone help me please?


0

Response Number 4
Name: Ned
Date: August 29, 2002 at 13:11:53 Pacific
Reply:

Your whole script required to be rewritten.
Nothing seems to be okay in it will require time.

Will try to do it in next sitting.


0

Response Number 5
Name: Bobbi
Date: September 1, 2002 at 12:39:51 Pacific
Reply:

ok
thanks
i thought some of it was ok ?


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: script with word count compare

word count www.computing.net/answers/unix/word-count/7656.html

Word count in unix www.computing.net/answers/unix/word-count-in-unix/7143.html

scan ascii file and do calculation www.computing.net/answers/unix/scan-ascii-file-and-do-calculation/4328.html