Unable to Print Count


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to Print Count
# 1  
Old 01-23-2012
Unable to Print Count

Hi All,


I am performing addition of two inetger variables which assigning output to a new variable getting following error.


Check1.sh
Code:
#!/bin/ksh
filesrc=/usr/kk/Source1.txt
filetgt=/usr/kk/Source2.txt
 
FINAL_COUNTS= `awk '{n++} END {printf "%012d\n",n}' ${filesrc} ${filetgt}`
 
echo 'Final Count is:'$FINAL_COUNTS

Below is the output:

Code:
 
+ awk {n++} END {printf "%012d\n",n} /usr/kk/Source1.txt /usr/kk/Source2.txt
+ 000000000014
+ FINAL_COUNTS=
./Check1.sh[5]: 000000000014:  not found.

# 2  
Old 01-23-2012
Replace space before awk :
Code:
#!/bin/ksh
filesrc=/usr/kk/Source1.txt
filetgt=/usr/kk/Source2.txt
 
FINAL_COUNTS=`awk '{n++} END {printf "%012d\n",n}' ${filesrc} ${filetgt}`
 
echo 'Final Count is:'$FINAL_COUNTS

or add quotes if you wat a space before count in FINAL_COUNTS :
Code:
#!/bin/ksh
filesrc=/usr/kk/Source1.txt
filetgt=/usr/kk/Source2.txt
 
FINAL_COUNTS=" `awk '{n++} END {printf "%012d\n",n}' ${filesrc} ${filetgt}`"
 
echo 'Final Count is:'$FINAL_COUNTS

Jean-Pierre.
This User Gave Thanks to aigles For This Post:
# 3  
Old 01-23-2012
Thanks its worked
# 4  
Old 01-23-2012
Wouldn't this suffice?
Code:
FINAL_COUNT=`printf "%012d" $(cat $filesrc $filetgt | wc -l)`

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print count of unique values

Hello experts, I am converting a number into its binary output as : read n echo "obase=2;$n" | bc I wish to count the maximum continuous occurrences of the digit 1. Example : 1. The binary equivalent of 5 = 101. Hence the output must be 1. 2. The binary... (3 Replies)
Discussion started by: H squared
3 Replies

2. Shell Programming and Scripting

Unable to print block of data

Hi All, Iam unable to print the below block and getting the error.Can anyone please help me in this. Input Data eaits001z$ echo "-------LINENO_JOBID_VAL--------${LINENO_JOBID_VAL}---" -------LINENO_JOBID_VAL--------58167|253473 58169|253473 58171|253473 58179|253473 58180|253473 58181|257311... (9 Replies)
Discussion started by: cskumar
9 Replies

3. Shell Programming and Scripting

Count and print the number of occurences

I have some files as shown below GLL ALM 654-656 654 656 SEM LYG 655-657 655 657 SEM LYG 655-657 655 657 ALM LEG 656-658 656 658 ALM LEG 656-658 656 658 ALM LEG 656-658 656 658 LEG LEG 658-660 658 660 LEG LEG 658-660 658 660 The value of GLL is... (5 Replies)
Discussion started by: arch
5 Replies

4. Shell Programming and Scripting

Count Column and Print at last

HI Guys, Count base on column A Input:- U00393 6 000100000 U00393 7 000100001 U00393 8 000100002 U00393 9 000100003 U00393 10 000100004 U00393 11 000100005 U00928 6 000100000 U00928 7 000100001 U00964 6 000100000 U00964 7 000100001 U00964 8 000100002 U00972 6 000100000 U00972... (3 Replies)
Discussion started by: asavaliya
3 Replies

5. Shell Programming and Scripting

Unable to print dynamic arguments in for loop

Hi All, I want to pass few dynamic arguments to shell script. The number of arguments differ each time I call the script. I want to print the arguments using the for loop as below. But not working out. for (( i=1; i<=$#; i++ )) do echo $"($i)" done /bin/sh test.sh arg1 arg2 arg3 ... (1 Reply)
Discussion started by: laalesh
1 Replies

6. Shell Programming and Scripting

Search, group , print count

hi All, need help. have a file like below A, error in 123 B, log files are present A, error in 23444 B, log files are present A, move to next line C, matching messages -- expected output-- A , count =2 , error in * A , count =1 , move to next line B , count =2 , log files are present... (2 Replies)
Discussion started by: arun1401
2 Replies

7. Shell Programming and Scripting

Count and print all repeating words in a line

Gurus, I have a file containing lines like this : Now, number of words in each line varies. My need is, if a word repeats in a line get it printed. Also total number of repeats. So, the output would be : Any help would be highly appreciated. Thanks & Regards (5 Replies)
Discussion started by: AshwaniSharma09
5 Replies

8. Shell Programming and Scripting

count identical strings print last row and count

I have a sorted file like: Apple 3 Apple 5 Apple 8 Banana 2 Banana 3 Grape 31 Orange 7 Orange 13 I'd like to search $1 and if $1 is not the same as $1 in the previous row print that row and print the number of times $1 was found. so the output would look like: Apple 8 3 Banana... (2 Replies)
Discussion started by: dcfargo
2 Replies

9. AIX

Unable to print Cyrillic fonts

Hi All I confifured HP 4250 printer on AIX server..I am unable to print cyrillic fonts prints. Please assist.. (0 Replies)
Discussion started by: kandatihari
0 Replies

10. SCO

Non-Root Users Unable to Print

UnixWare 7, Release 7.1.3 We have a customer that has frequent issues with Non-Root users being unable to print. They are able to print w/o issues, but all of the sudden it stops working. The only workaround we have at this point is to reboot the server. It is happening weekly according to... (1 Reply)
Discussion started by: cfshd
1 Replies
Login or Register to Ask a Question