Sponsored Content
Full Discussion: Validation of variable
Top Forums Shell Programming and Scripting Validation of variable Post 302543923 by vgersh99 on Tuesday 2nd of August 2011 11:53:12 AM
Old 08-02-2011
either:
Code:
function alert_stock
{
    qtyA=`cat stockDB.txt | cut -d: -f4`
    if [ "$qtyA" -lt 3 ]; then

    echo $qtyA

    fi
}

the above performs the numerical comparison (unlike '<' which is alphabetical).
OR
Code:
awk -F: '{printf "%-1s,%-10s\n", $1, int($4)<3}' stockDB.txt

some awk-s are more picky than the others.
This User Gave Thanks to vgersh99 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Input validation ?

I am trying to validate user input, at the moment what i have is as below :- echo "\n\tPlease, enter package name to import: \c" read PACKAGE So far this works perfect , But if the user does not input any thing it stalls :( What I need is, If the user does not enter the name of the... (9 Replies)
Discussion started by: systemali
9 Replies

2. UNIX for Dummies Questions & Answers

validation on a parameter

Hi guys! Im tryin to set up a login script that allows a user to login with only the following "forename.surname" . The username all contain lowercase letters so thats not a problem to sort out, but im having problems making sure that they can only enter 1 " . " . the code i have so far is this... (1 Reply)
Discussion started by: Henley55
1 Replies

3. UNIX for Dummies Questions & Answers

Validation

I'm kinda new in shell scripting. How do i validate an input from a user to conform to requirement. For example, echo "Enter First Name: " read FName echo "Enter Date of Employment (dd/mm/yyyy): " read DoE If the user enters data that is alphanumeric, it accepts it. I hope i've... (1 Reply)
Discussion started by: Allenzo
1 Replies

4. Web Development

Validation in php help !

I am validating a form using php script and I want to "echo" the error message near to the text box itself & not below all the controls....Can I Position the display messages ?..Pls help me... (2 Replies)
Discussion started by: gameboy87
2 Replies

5. Shell Programming and Scripting

Validation help

Hi, I am new to Unix shell scripting and need help to add some validation to an existing script. I've made a script that takes two argument (input) but I want the script to display an error message when nothing (null) is entered. So far I managed to validate the fist argument but fail to... (2 Replies)
Discussion started by: zen10
2 Replies

6. Shell Programming and Scripting

Name validation

Hi All, I need to write a small piece of code to check the following. name should contain (A-Z), spaces, hyphens & apostrophes I need to generate regular expressions for the same. Please help me out as i am not familiar with regular expressions. (1 Reply)
Discussion started by: lifzgud
1 Replies

7. Shell Programming and Scripting

Variable Validation

Hi Guys, I am getting count from a file (pipe delimited). "23"|"9896"|"20090101"|"New Load" I am using the following code to get the first two counts. CtrlFileByte=`/bin/gawk -F"|" '{ print $1 }' $ControlFile`; CtrlFileCnt=`/bin/gawk -F"|" '{ print $2 }' $ControlFile`; But the... (2 Replies)
Discussion started by: mac4rfree
2 Replies

8. Shell Programming and Scripting

File validation

Hi there, As a part of file validation, I needed to check for delimiter count in the file. My aim is to find, how many records have failed to have predefined numbers of delimiters in the file. My code looks like below i=`awk -F '|' 'NF != 2 {print NR, $0} ' ${pinb_fldr}/${pfile}DAT |... (3 Replies)
Discussion started by: anandapani
3 Replies

9. Shell Programming and Scripting

Value validation

Hi All I am trying to validate a value using if condition requirement is need to check whether its a valid numeric value the input contains ( space, #N/A and negative and positive decimal values and Zeros) if it contains the space, I need to display the error message as space ... (15 Replies)
Discussion started by: tsurendra
15 Replies

10. UNIX for Beginners Questions & Answers

Validation using While and IF

I am learning Shell scripting on own. I am trying to do an assignment to get details from the user like username their individual marks ,DOB and send a report in mail with the Details calculated like total and average. validate_marks() { local Value=$1 if && then return 0 else... (1 Reply)
Discussion started by: JayashreeRobin
1 Replies
Validation::Class::Backwards(3pm)			User Contributed Perl Documentation			 Validation::Class::Backwards(3pm)

NAME
Validation::Class::Backwards - Backwards-Compatibility Layer for Validation::Class VERSION
version 7.70 SYNOPSIS
package SomeClass; use Validation::Class; package main; my $class = SomeClass->new; ... 1; DESCRIPTION
Validation::Class::Backwards is responsible for providing deprecated functionality to the Validation::Class::Prototype layer whilst clearly remaining separate via namespacing. Note: The methods described here will eventually become obsolete and cease to exist. Please review the namespace occasionally and adjust your code accordingly. Using methods defined here will generate warnings unless you unset the $ENV{'VALIDATION_CLASS_BC_WARNING'} environment variable. METHODS
error DEPRECATING: The error method is used to set and/or retrieve errors encountered during validation. The error method with no parameters returns the error message object which is an arrayref of error messages stored at class-level. # set errors at the class-level return $self->error('this isnt cool', 'unknown somethingorother'); # set an error at the field-level, using the field ref (not field name) $self->error($field_object, "i am your error message"); # return all errors encountered/set as an arrayref my $all_errors = $self->error(); RECOMMENDED: # see Validation::Class::Errors # set errors at the class-level return $self->errors->add(...); # set an error at the field-level $self->fields->{$field_name}->{errors}->add(...); # return all errors encountered my $list = $self->errors->list; AUTHOR
Al Newkirk <anewkirk@ana.io> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Al Newkirk. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-28 Validation::Class::Backwards(3pm)
All times are GMT -4. The time now is 06:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy