I am trying to get a count of the number of characters per line in a file by name Application.log by doing a
#!/bin/ksh
for lines in $(cat Application.log)
do
count=$(echo $lines | wc -c)
echo $lines char count: $count >> WC.out
done
I am getting the character count and in addition to that, I also get the number of characters for each of the files present in the directory I am executing the script from, just so that its more clear, I am including the output of the script:
005-05-11 char count: 11
16:02:48,317 char count: 13
| char count: 2
ExecuteThread: char count: 15
'22' char count: 5
for char count: 4
queue: char count: 7
'weblogic.kernel.Default' char count: 26
| char count: 2
[DEBUG] char count: 8
| char count: 2
com.onstar.vehcomm.logging.LogHandler char count: 38
| char count: 2
- char count: 2
backup char count: 7
CountChars.sh char count: 14
Application.log char count: 21
Application.log.1 char count: 23
Application.log.10 char count: 24
Application.log.11 char count: 24
Application.log.2 char count: 23
Application.log.3 char count: 23
Application.log.4 char count: 23
Application.log.5 char count: 23
Application.log.6 char count: 23
Application.log.7 char count: 23
Application.log.8 char count: 23
Application.log.9 char count: 23
Questions -
* Is there a better way of getting the count?
* Why am I getting the character count for file names though I am targeting Application.log in my script? (Application.log doesnt have any lines like Application.log.9 etc)
Appreciate any help
#!/bin/ksh
for lines in $(cat Application.log)
do
count=$(echo $lines | wc -c)
echo $lines char count: $count >> WC.out
done
I am getting the character count and in addition to that, I also get the number of characters for each of the files present in the directory I am executing the script from, just so that its more clear, I am including the output of the script:
005-05-11 char count: 11
16:02:48,317 char count: 13
| char count: 2
ExecuteThread: char count: 15
'22' char count: 5
for char count: 4
queue: char count: 7
'weblogic.kernel.Default' char count: 26
| char count: 2
[DEBUG] char count: 8
| char count: 2
com.onstar.vehcomm.logging.LogHandler char count: 38
| char count: 2
- char count: 2
backup char count: 7
CountChars.sh char count: 14
Application.log char count: 21
Application.log.1 char count: 23
Application.log.10 char count: 24
Application.log.11 char count: 24
Application.log.2 char count: 23
Application.log.3 char count: 23
Application.log.4 char count: 23
Application.log.5 char count: 23
Application.log.6 char count: 23
Application.log.7 char count: 23
Application.log.8 char count: 23
Application.log.9 char count: 23
Questions -
* Is there a better way of getting the count?
* Why am I getting the character count for file names though I am targeting Application.log in my script? (Application.log doesnt have any lines like Application.log.9 etc)
Appreciate any help