Sponsored Content
Full Discussion: Programming logic help
Top Forums Shell Programming and Scripting Programming logic help Post 302813815 by brunlea on Tuesday 28th of May 2013 07:48:20 AM
Old 05-28-2013
Programming logic help

Hi,

I was having a problem regarding this thread:
HTML Code:
https://www.unix.com/shell-programming-scripting/225221-setting-variable-using-variables-loop.html
I have not been able to solve that issue. So i was thinking maybe my logic to solve the overall problem is wrong, so i am looking for a bit of help on what would be a good way to approach the following task.

I have a list of 24 files that are produced daily. On some days all 24 files may not be produced. The filenames are in the format filename-2digitnumber ( e.g. log-01). In each of the files, i need to search for an occurrence of a particular word and see how many times it occurs. Once i have the occurrences per file, i then need to total up all the occurrences per file into a grand total.

The way i have gone about this was to do a for loop, which had an if statement within it which did a check to see if the file existed. Then I would do a count on the file and assign it to a variable, that is also a variable. I get stuck at this stage as in the above thread. Code example:

Code:
file=log

for i in 01 02 03; do
if [ -f $file-$i ]; then
count$i=`grep -c word $file-$i`
fi
done

for i in 01 02 03; do 
if [ ! -z "$count$i" ]; then
:
else Tcount=`expr $Tcount + $count$i`
fi
done

Any ideas on how to go about this will be appreciated.

Thanks
 

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need a logic for awk programming

Hello Friends, I have a txt file like below //*Init Start Reg(read,12'h42E,16'h0000); Nop(5628.5); //*Init End //*Main Start Reg(read,12'h42E,16'h0000); Nop(5628.5); //*Main End I want to calculate the values between //* Init Start & //* Init End And //*Main Start & //*Main... (5 Replies)
Discussion started by: user_prady
5 Replies

2. Shell Programming and Scripting

More a logic than a programming question

hello, I'm a littlebit lost... i have a table of single names and combination of two names and i want a table of ALL single names with ALL combinations (also the indirect ones). - - - in reality the names are longer, not only a,b,.. and the table is tab-delimited, and the result table... (6 Replies)
Discussion started by: dietmar13
6 Replies
platform::shell(3tcl)					       Tcl Bundled Packages					     platform::shell(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
platform::shell - System identification support code and utilities SYNOPSIS
package require platform::shell ?1.1.4? platform::shell::generic shell platform::shell::identify shell platform::shell::platform shell _________________________________________________________________ DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell. This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only requirement is that the other shell (identified by its path), is actually executable on the current machine. While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run 32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers. For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed packages, versus the architecture of the shell running the repository software. COMMANDS
platform::shell::identify shell This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell. platform::shell::generic shell This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell. platform::shell::platform shell This command returns the contents of tcl_platform(platform) for the specified Tcl shell. KEYWORDS
operating system, cpu architecture, platform, architecture platform::shell 1.1.4 platform::shell(3tcl)
All times are GMT -4. The time now is 11:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy