Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line count in shell script. 1

Status
Not open for further replies.

dUbbsNIX

MIS
Jul 10, 2003
70
GB
I need to get a line count of two scripts and the calculate the differnce in
lines, so I can tail the latest amount. I have imagined it to be something like
below, but cant get the total to work!!


count1='cat /u01/app/oracle/admin/ARERDK/bdump/alert_RDK.log|wc -l'
count2='cat /home/redeye/G.exall/pmon.log|wc -l'
total=$count1-$count2

Dubbs
 
Try this:
total=`expr $count1 - $count2`

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Try this:
total=`expr $count1 - $count2`
If your shell is ksh (or compatible):
total=$((count1-count2))

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Try:

count1=`wc -l /u01/app/oracle/admin/ARERDK/bdump/alert_RDK.log|tr -s ' ' | cut -f2 -d' '`
count2=`wc -l /home/redeye/G.exall/pmon.log| tr -s ' ' | cut -f2 -d' '`
total=`expr $count1 - $count2`

Note the ` surrounding the expessions are back ticks, not regular apostrophes.

 
Many thanks for everyones' help. This has been sorted now, here's the email from the person on who's behalf I posted the query.

cheers mate, I have infact managed to get it to work

total="`expr $count1 - $count2`"

I had the wrong quotes!!!!!

thanks anyway mate
 
Nice segue:

Back ticks have been deprecated in Bourne Shell derivatives for YEARS, since about 1993.

The preferred shell construct is $( command ). Try nesting two sets of back ticks inside one another and you'll see the benefit, besides the lack of 'oops, I had the wrong quotes' problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top