Sponsored Content
Full Discussion: For loop error
Top Forums UNIX for Beginners Questions & Answers For loop error Post 303043810 by RudiC on Friday 7th of February 2020 09:13:20 AM
Old 02-07-2020
Difficult ... where to start?
Well, this is what (including some inconsistencies) I get from your code snippet after having eliminated the gravest syntax problems:
Code:
$ cat /tmp/output.txt
test_[name]_[service1]_[1]
.
.
.
test_[name]_[service15]_[6]
test_[sh1]_[service1]_[1]
.
.
.
test_[sh1]_[service1]_[6]
test_[sh1]_[service15]_[1]
.
.
.
test_[sh1]_[service15]_[6]
test_[sh16]_[service1]_[1]

The largest problem seems to be the test_[$i]_[$j]_[$k] =cat /tmp/filename.txt | grep $i | grep $j | grep $k | wc -l:
- that ...[...]...[...]... is not a construct known to me, at least in the most commen shells. BTW, what's your shell? You forgot to mention...
- (common) shells don't like a space around the = . That's the reason for your error msg.
- the cat ...pipe needs to be run in a "command substitution" $(...) (c.f. man bash or your shell's man page)

You seem to have missed the "expansion" of the variable in the echo statement.
I don't see any relation to your output sample from the structure of your script. And, there's no service16 mentioned anywhere except in your output.



Aside: be aware of "false positives" (like sh1 matching sh1 AND sh16).
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Error in for loop?

Hi, Working on AIX using the following for loop. for a in `find /edi/iTracTEST/sessions -name nohup.out -print` do echo $a done On the command line it works fine, but insert the code in a file and then running it, it does not want to work. I get the following back. ' is not... (3 Replies)
Discussion started by: hugow
3 Replies

2. Shell Programming and Scripting

Error in Loop?

hi friends, i wrote one simple shell script.. in that am using for loop... when i am trying to execute the script.it shows syntax error at for loop line '((' unexpected. #!/bin/ksh ## ##### To find no of files in the directory NOF=`ls -l /root/COMM/LOGS/eds/20081025| wc -l`... (5 Replies)
Discussion started by: rdhaprakasam
5 Replies

3. UNIX for Dummies Questions & Answers

error in for loop???

Hi, I get the following output 98 -1 98 0 ./get_AB04-time: line 79: ((: i< && 0 !=7 : syntax error: operand expected (error token is "&& 0 !=7 ") I have this part of code. Line 79 is the line of the for loop. echo ${OCCURRENCE} $i_START CASE=0; i_END=${i_START}... (4 Replies)
Discussion started by: f_o_555
4 Replies

4. Shell Programming and Scripting

Error Using an if Loop Within a While Loop

Hello All, I am having a problem with an “if loop” within a “while loop” in my Korn Shell program. The basic concept of the program is that it searches for the existence of a series of load files in a load directory, and once it finds one of these files, it begins the following process: · Creates... (4 Replies)
Discussion started by: jonesdk5
4 Replies

5. Shell Programming and Scripting

Error with while loop

the program just prints all the command line arguments Getting error in the program error ./hellow: line 13: 0: command not found ./hellow: line 13: 0: command not found below is the program #!/bin/bash num=$# echo $num if then echo "No arguments are passed ." else ... (7 Replies)
Discussion started by: BHASKARREDDY006
7 Replies

6. Shell Programming and Scripting

Error in while loop

I have a file Table.out having table name like this Table_Emp Table_Exp Table_Fcr To show first 10 rows .. I' wrtng a script like this .. #!/bin/ksh cat /tmp/table.out|while read -r table vbar1 do <connect to db> then select * from $table limit 10; > /tmp/1.out done ... (3 Replies)
Discussion started by: netdbaind
3 Replies

7. Shell Programming and Scripting

Getting error in if loop

Hi All, while executing this code ,I'm gettign below Error if_test: line 3: #!/bin/bash if ; then echo "this is aginity;" elif ; then echo "this is informatica;" fi exit (3 Replies)
Discussion started by: netdbaind
3 Replies

8. Shell Programming and Scripting

Error in loop

This is my first ever bash script. What i wish to achieve is to find all files in current directory except the script file and count lines in each found file. Some thing seems to be wrong with the if statement :confused: Please help why it does not work? and maybe you have some ideas how to improve... (3 Replies)
Discussion started by: chinababy
3 Replies

9. Shell Programming and Scripting

Error in for loop

I was trying to implement a nested for do loop to run a perl script. for i in 1 10 50 do for j in 2 12 55 do perl script.pl "$i" "$i" "$j" done done when I implemented it within a shell script, i got the output, but every time j value will 55, or basically the last value of j in... (10 Replies)
Discussion started by: Kanja
10 Replies

10. UNIX for Beginners Questions & Answers

Error with for loop

There are two files abc_123.dat and abc_345.dat if at least one file exists then enter into the loop and remove file and exit. In first iteration, deleting files successfully but "else" statement executing after deleting files."else" should execute only if there is no file in the directory.... (1 Reply)
Discussion started by: Rajesh123
1 Replies
Math::Symbolic::Custom(3pm)				User Contributed Perl Documentation			       Math::Symbolic::Custom(3pm)

NAME
Math::Symbolic::Custom - Aggregate class for tree tests and transformations SYNOPSIS
# Extending the class: package Math::Symbolic::Custom::MyTransformations; use Math::Symbolic::Custom::Base; BEGIN {*import = &Math::Symbolic::Custom::Base::aggregate_import} our $Aggregate_Export = [qw/apply_transformation1 .../]; sub apply_transformation1 { # ... } # ... # Using the custom class: use Math::Symbolic; use Math::Symbolic::Custom::MyTransformations; # later... $tree->apply_transformation1(); $tree->mod_transformation2(); die unless $tree->is_type1(); die unless $tree->test_condition1(); die if $tree->contains_something1(); print $tree->to_latex(); DESCRIPTION
This is an aggregate class for all custom modification, transformation, testing and output extensions for Math::Symbolic trees. Some default transformations and tests are implemented in the Math::Symbolic::Custom::DefaultMods and Math::Symbolic::Custom::DefaultTests packages, default output routines in Math::Symbolic::Custom::DefaultDumpers which are automatically loaded by the Math::Symbolic::Custom class. Math::Symbolic::Custom imports all constants from Math::Symbolic::ExportConstants EXPORT None by default. EXTENDING THE MODULE
In order to extend the functionality of Math::Symbolic, you have to go through the following steps: (also see the synopsis in this document.) o Choose an appropriate namespace in the Math::Symbolic::Custom::* hierarchy or if you desparately wish, somewhere else. o Create a new module (probably using "h2xs -AX MODULENAME") and put the following lines of code in it: # To make sure we're cooperating with Math::Symbolic's idea of # method delegation. use Math::Symbolic::Custom::Base; BEGIN {*import = &Math::Symbolic::Custom::Base::aggregate_import} our $Aggregate_Export = [ # Put the list of method names to be exported. /]; o Think well about the naming of your exported methods. Answer the following questions: Does the name start with 'is_', 'test_', 'mod_', 'apply_', 'contains_', or 'to_'? If not, find a suitable name that does. Does the name clash with any of the methods exported by Math::Symbolic::Custom::DefaultTests, Math::Symbolic::Custom::DefaultMods, or Math::Symbolic::Custom::DefaultDumpers? If so, please consider choosing a different name. Does the name map to the idea behind the method prefix ('is_', ...)? Only methods starting with one of the prefixes listed above can be delegated. Any others will never be called. The idea behind delegating methods with several prefixes is to provide for a reasonable choice for naming methods. 'is_' and 'contains_' are meant to be used for accurate tests like "is_constant". 'test_' is meant for all tests that either make use of heuristics or can't be fitted into either 'is_' or 'contains_'. The prefixes 'mod_' and 'apply_' are meant for use with methods that modify the Math::Symbolic tree. Finally, the prefix 'to_' is meant to be used with conversion and output methods like 'to_latex' or 'to_string'. (Though as of version 0.122, to_string is implemented in the core Math::Symbolic modules.) o Make sure you document exactly what your methods do. Do they modify the Math::Symbolic tree in-place or do they clone using the new() constructor and return a copy? Make sure you mention the behaviour in the docs. o Consider packaging your extensions as a CPAN distribution to help others in their development with Math::Symbolic. If you think the extensions are generic enough to be a worthwhile addition to the core distribution, try sending your extensions to the Math::Symbolic developers mailing list instead. o Load your extension module after loading the Math::Symbolic module. o Start using your custom enhancements as methods to the Math::Symbolic trees (any term types). o Send bug reports and feedback to the Math::Symbolic support mailing list. AUTHOR
Please send feedback, bug reports, and support requests to the Math::Symbolic support mailing list: math-symbolic-support at lists dot sourceforge dot net. Please consider letting us know how you use Math::Symbolic. Thank you. If you're interested in helping with the development or extending the module's functionality, please contact the developers' mailing list: math-symbolic-develop at lists dot sourceforge dot net. List of contributors: Steffen Mueller, symbolic-module at steffen-mueller dot net Stray Toaster, mwk at users dot sourceforge dot net Oliver Ebenhoeh SEE ALSO
New versions of this module can be found on http://steffen-mueller.net or CPAN. The module development takes place on Sourceforge at http://sourceforge.net/projects/math-symbolic/ Math::Symbolic::Custom::Base Math::Symbolic::Custom::DefaultTests Math::Symbolic::Custom::DefaultMods Math::Symbolic::Custom::DefaultDumpers Math::Symbolic perl v5.10.1 2011-01-01 Math::Symbolic::Custom(3pm)
All times are GMT -4. The time now is 01:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy