How to validate a column?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to validate a column?
# 1  
Old 11-02-2008
How to validate a column?

Dear guru's,

I am learning shellscripting and now I 'm struggeling with this problem:
When the number in the left column is equal or higer then 200, I want to send an email to "postmaster" @ the corresponding domain in the right column.


220 shoes.com
217 dishwashers.net
209 cars.org
201 bikes.gov
175 beer.org
160 wine.net
154 food.com
148 paintball.com
132 pingpong.net
122 macaroni.com


I can't find out how to do this. Please help.
Thanks a bunch.
Regs, A.
# 2  
Old 11-02-2008
Code:
while read num domain
do
   if [[ $num -ge 200 ] ; then
        echo "postmaster@"$domain
   fi
done < inputfilename

# 3  
Old 11-02-2008
Quote:
Originally Posted by jim mcnamara
Code:
while read num domain
do
   if [[ $num -ge 200 ] ; then
        echo "postmaster@"$domain
   fi
done < inputfilename

Thanks Jim!

While testing I bumped into this syntax error

./validate.sh: line 4: syntax error in conditional expression
./validate.sh: line 4: syntax error near `]'
./validate.sh: line 4: ` if [[ $num -ge 200 ] ; then'


What is going on here?
Cheers, A.
# 4  
Old 11-02-2008
Remove the brace..

Remove a brace from if loop..

Same code with modification...

while read num domain
do
if [ $num -ge 200 ] ; then
echo "postmaster@"$domain
fi
done < inputfilename


Try this..
# 5  
Old 11-02-2008
Quote:
Originally Posted by muruganksk
Remove a brace from if loop..

Same code with modification...

while read num domain
do
if [ $num -ge 200 ] ; then
echo "postmaster@"$domain
fi
done < inputfilename


Try this..
Thank you, I went past that error on line 4 now.
There seems to remain one last problem with the inputfile as you can see below. The file "columns.txt" is executed by the owner and perms are 755. What is bash complaining about?

./validate.sh: line 7: syntax error near unexpected token `done'
./validate.sh: line 7: `done < /export/home/john/columns.txt'


Thanks again!
# 6  
Old 11-02-2008
can you post your scripplet over here.. So that I can have a look.
# 7  
Old 11-02-2008
can you post your scriplet over here.. So that I can have a look.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Difference of the same column when two other column matches and one column differs less than 1 hour

This is my input file : # cat list 20130430121600, cucm, location,76,2 20130430121600,cucm1,location1,76,4 20130430122000,cucm,location,80,8 20130430122000,cucm1,location1,90,8 20130430140000,cucm1,location1,87,11 20130430140000, cucm,location,67,9 This is the required output ... (1 Reply)
Discussion started by: Lakshmikumari
1 Replies

2. Shell Programming and Scripting

validate timestamp

How to validate the user supplied timestamp? Ther requirement is as follows. While invoking the script, the parameters passed to the script are minimum and maixmum timestamps. let's say min_tstmp and max_tstmp ksh abc.ksh 2011-09-01-00:00:00 2011-12-01-00:00:00 so... (3 Replies)
Discussion started by: kmanivan82
3 Replies

3. Shell Programming and Scripting

Need to validate that all 24 hr are in a table

I have a table that looks like this, but for a whole year: Hourly weather history for XXX 7 Jun 0:00 Clear weather 28 1:00 Clear weather 23 2:00 Clear weather 21 3:00 Clear weather 22 4:00 Clear weather 22 5:00 Clear weather 22 6:00 Clear weather 23 7:00 Clear... (12 Replies)
Discussion started by: paulyester
12 Replies

4. Shell Programming and Scripting

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 file 1 sample SNDK 80004C101 AT XLNX 983919101 BB NETL 64118B100 BS AMD 007903107 CC KLAC 482480100 DC TER 880770102 KATS ATHR 04743P108 KATS... (7 Replies)
Discussion started by: rydz00
7 Replies

5. Shell Programming and Scripting

Validate and Calculate

Hi, i am trying to validate 2 variables and then subtract, the following code works well in AiX but when i try in Solaris it doesnt work. ((TIME1>TIME2)) && ((TIME2=TIME2+864)) ((DIF=TIME2-TIME1)) echo difference = $DIF Seconds is there any way the validation can be done using... (2 Replies)
Discussion started by: Shellslave
2 Replies

6. Shell Programming and Scripting

Changing one column of delimited file column to fixed width column

Hi, Iam new to unix. I have one input file . Input file : ID1~Name1~Place1 ID2~Name2~Place2 ID3~Name3~Place3 I need output such that only first column should change to fixed width column of 15 characters of length. Output File: ID1<<12 spaces>>Name1~Place1 ID2<<12... (5 Replies)
Discussion started by: manneni prakash
5 Replies

7. Shell Programming and Scripting

How to validate an IP address

hi I need a simple script to do the following. I need to check the user input for 1. quad dotted notation. 2. check that all of the inputs are numeric and within 1-255 range. Could someone please help me? I tried to use egrep to check for dotted notation. quad=1.1.1.12 ... (5 Replies)
Discussion started by: sabina
5 Replies

8. Shell Programming and Scripting

How to Validate

I have one script by which I am taking Extraction Schedule in the following format ,,,...... Here I want validate the Input from user is okey or not. Let say i have one variable SCH SCH=12:34,23:12,11:20 Could you please tell me how I will validate it. HH & MM Both should be Numeric HH... (10 Replies)
Discussion started by: SanjayLinux
10 Replies

9. Shell Programming and Scripting

Better way to Validate column data in file.

I am trying to validate the third column in a pipe delimited file. The column must be 10 char long and all digits 0-9. I am writing out two new files from the existing file, if it would be quicker, I could leave the bad rows in the file and ignore them in the next process. What I have is... (12 Replies)
Discussion started by: barry1
12 Replies

10. Shell Programming and Scripting

validate

hi need help here, a bit of code im doing requires a number to be enetered i have got validation and loop if its outside a ceratain range, but was wondering what code i need to validate if a character has been entered. cheers (3 Replies)
Discussion started by: ruffenator
3 Replies
Login or Register to Ask a Question