Sponsored Content
Full Discussion: While loop for comparison
Top Forums Shell Programming and Scripting While loop for comparison Post 302805963 by Don Cragun on Sunday 12th of May 2013 12:21:50 AM
Old 05-12-2013
This is not the appropriate forum for homework assignments.

Why would you insist on a while loop to perform comparisons? A very simple awk script would be easier (and more efficient than many common while loops that would perform this task).
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with if loop (string comparison)

Hi Can someone please tell me what is wrong with this (ksh).. if + ]] then echo ${COMP_TEMP} fi What i need here is, say if the variable is a 1 or 2 digit number, then execute the if loop. Basically the variable can either be 1-30 or some other character sequence say '?', '&&'... (4 Replies)
Discussion started by: psynaps3
4 Replies

2. UNIX for Advanced & Expert Users

Comparison and For Loop Taking Too Long

I'd like to 1. Check and compare the 10,000 pnt files contains single record from the /$ROOTDIR/scp/inbox/string1 directory against 39 bad pnt files from the /$ROOTDIR/output/tma/pnt/bad/string1 directory based on the fam_id column value start at position 38 to 47 from the record below. Here is... (1 Reply)
Discussion started by: hanie123
1 Replies

3. Shell Programming and Scripting

Comparison and editing of files using awk.(And also a possible bug in awk for loop?)

I have two files which I would like to compare and then manipulate in a way. File1: pictures.txt 1.1 1.3 dance.txt 1.2 1.4 treehouse.txt 1.3 1.5 File2: pictures.txt 1.5 ref2313 1.4 ref2345 1.3 ref5432 1.2 ref4244 dance.txt 1.6 ref2342 1.5 ref2352 1.4 ref0695 1.3 ref5738 1.2... (1 Reply)
Discussion started by: linuxkid
1 Replies

4. Shell Programming and Scripting

Expect - Comparison of expect value and loop selection

Hello All, I am trying to automate an installation process using expect and sh script. My problem is that during the installation process the expected value can change according to the situation. For Example if this is a first time installation then at step 3 I'll get "Do you want to accept... (0 Replies)
Discussion started by: alokrm
0 Replies

5. Shell Programming and Scripting

String comparison not working inside while loop

Hi, In the code included below, the string comparision is not working fine. Please help while (( find_out >= i )) do file=`head -$i f.out|tail -1` dir=`dirname $file` cd $dir Status="" if ; then Status=`cvs -Q status... (3 Replies)
Discussion started by: sudvishw
3 Replies

6. Shell Programming and Scripting

string comparison not working inside while loop

The string comparison highlighted below is not working fine. Please help: while read line do # Get File name by deleting everything that preceedes and follows Filename as printed in cvs status' output f_name=`echo $line | sed -e 's/^File://' -e 's/ *Status:.*//' | awk '{print $NF}'` ... (4 Replies)
Discussion started by: sudvishw
4 Replies

7. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

8. Shell Programming and Scripting

Comparison of two variables with IF loop

Hello, My script is like : #!/bin/sh -x TODAY=$(echo `date +"%b%d"`) FILE_DATE=$(ls -l test.sh | awk '{print $6$7}') echo "file date=$FILE_DATE" echo "date=$TODAY" if ];then echo "file is correct" else echo "file is incorrect" fi and The Output is : $ ./test.sh + + date +%b%d +... (3 Replies)
Discussion started by: saurau
3 Replies

9. Shell Programming and Scripting

awk loop using array:wish to store array values from loop for use outside loop

Here's my code: awk -F '' 'NR==FNR { if (/time/ && $5>10) A=$2" "$3":"$4":"($5-01) else if (/time/ && $5<01) A=$2" "$3":"$4-01":"(59-$5) else if (/time/ && $5<=10) A=$2" "$3":"$4":0"($5-01) else if (/close/) { B=0 n1=n2; ... (2 Replies)
Discussion started by: klane
2 Replies

10. Shell Programming and Scripting

awk - 2 files comparison without for loop - multi-line issue

Greetings Experts, I need to handle the views created over monthly retention tables for which every new table in YYYYMMDD format, there is equivalent view created and the older table which might be dropped, the view over it has to be re-created over a dummy table so that it doesn't fail.... (2 Replies)
Discussion started by: chill3chee
2 Replies
CGI::FormBuilder::Source::YAML(3pm)			User Contributed Perl Documentation		       CGI::FormBuilder::Source::YAML(3pm)

NAME
CGI::FormBuilder::Source::YAML - Initialize FormBuilder from YAML file SYNOPSIS
use CGI::FormBuilder; my $form = CGI::FormBuilder->new( source => { source => 'form.fb', type => 'YAML', }, ); my $lname = $form->field('lname'); # like normal DESCRIPTION
This reads a YAML (YAML::Syck) file that contains FormBuilder config options and returns a hash to be fed to CGI::FormBuilder->new(). Instead of the syntax read by CGI::FormBuilder::Source::File, it uses YAML syntax as read by YAML::Syck. That means you fully specify the entire data structure. LoadCode is enabled, so you can use YAML syntax for defining subroutines. This is convenient if you have a function that generates valida- tion subrefs, for example, I have one that can check profanity using Regexp::Common. validate: myfield: javascript: /^[sS]{2,50}$/ perl: !!perl/code: >- { My::Funk::fb_perl_validate({ min => 2, max => 50, profanity => 'check' })->(shift); } POST PROCESSING
There are two exceptions to "pure YAML syntax" where this module does some post-processing of the result. REFERENCES (ala CGI::FormBuilder::Source::File) You can specify references as string values that start with &, $, @, or \% in the same way you can with CGI::FormBuilder::Source::File. If you have a full direct package reference, it will look there, otherwise it will traverse up the caller stack and take the first it finds. For example, say your code serves multiple sites, and a menu gets different options depending on the server name requested: # in My::Funk: our $food_options = { www.meats.com => [qw( beef chicken horta fish )], www.veggies.com => [qw( carrot apple quorn radish )], }; # in source file: options: @{ $My::Funk::food_options->{ $ENV{SERVER_NAME} } } EVAL STRINGS You can specify an eval statement. You could achieve the same example a different way: options: eval { $My::Funk::food_options->{ $ENV{SERVER_NAME} }; } The cost either way is about the same -- the string is eval'd. EXAMPLE
method: GET header: 0 title: test name: test action: /test submit: test it linebreaks: 1 required: - test1 - test2 fields: - test1 - test2 - test3 - test4 fieldopts: test1: type: text size: 10 maxlength: 32 test2: type: text size: 10 maxlength: 32 test3: type: radio options: - - 1 - Yes - - 0 - No test4: options: @test4opts sort: &Someother::Package::sortopts validate: test1: /^w{3,10}$/ test2: javascript: EMAIL perl: eq 'test@test.foo' test3: - 0 - 1 test4: @test4opts You get the idea. A bit more whitespace, but it works in a standardized way. METHODS
new() Normally not used directly; it is called from CGI::FormBuilder. Creates the "CGI::FormBuilder::Source::YAML" object. Arguments from the 'source' hash passed to CGI::FormBuilder->new() will become defaults, unless specified in the file. parse($source) Normally not used directly; it is called from CGI::FormBuilder. Parses the specified source file. No fancy params -- just a single file- name is accepted. If the file isn't acceptable to YAML::Syck, I suppose it will die. SEE ALSO
CGI::FormBuilder, CGI::FormBuilder::Source AUTHOR
Copyright (c) 2006 Mark Hedges <hedges@ucsd.edu>. All rights reserved. LICENSE
This module is free software; you may copy it under terms of the Perl license (GNU General Public License or Artistic License.) http://www.opensource.org/licenses/index.html perl v5.8.8 2007-12-09 CGI::FormBuilder::Source::YAML(3pm)
All times are GMT -4. The time now is 09:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy