Validity


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Validity
# 1  
Old 12-04-2006
Validity

Hey, I was wondering how I could write a bash script which accepts:

Code:
cat <<% | bash ./results06
----------------------------------------------------------
                    Exam Results 2006
----------------------------------------------------------
 ________________________________________________________
|                                                        |
| The following table consists of exam results from      |
| a sample of students who took a course in expressive   |
| arts and were assessed via end of term modular exams.  |
|________________________________________________________|
|                                                        |
----------------------------------------------------------
|STID |Mod 1|  Mod 2 |  Mod 3  | Mod 4 | Mod 5  | Grade  |
----------------------------------------------------------
|801  | 56  |   70   |    80   |   96  |   70   |  PASS  |
|802  | 41  |   21   |    34   |   16  |   28   |  FAIL  |
|803  | 59  |   45   |    98   |   43  |   80   |  PASS  |
|804  | 78  |   99   |    87   |   79  |   90   |  PASS  |
|805  | 67  |   89   |    76   |   66  |   34   |  PASS  |
|806  | 34  |   70   |    29   |   14  |   8    |  FAIL  |
----------------------------------------------------------
In the following sample, the number of students who      
passed the course : 4
__________________________________________________________
%

from the standard input, checks the header and footer of the table for validity and only outputs the rows from the table, i.e:

Code:
|801  | 56  |   70   |    80   |   96  |   70   |  PASS  |
|802  | 41  |   21   |    34   |   16  |   28   |  FAIL  |
|803  | 59  |   45   |    98   |   43  |   80   |  PASS  |
|804  | 78  |   99   |    87   |   79  |   90   |  PASS  |
|805  | 67  |   89   |    76   |   66  |   34   |  PASS  |
|806  | 34  |   70   |    29   |   14  |   8    |  FAIL  |

Any help would be appreciated. Thanks!
# 2  
Old 12-04-2006
Gee, this sounds like homework - which is against the forum rules.
This requires grep ---

Code:
grep '^|[0-9]'  filename

Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Confirming validity of programming language tools

so i have scripts that get run in ways similar to this: cat script.pl | perl - $1 $2 $3 cat script.rb | ruby - $1 $ 2 $3 my question is, how can i verify that that the "perl" or "ruby" or "python" tool being run on the box is actually a legit tool? meaning, someone may move the tool from... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Shell Programming and Scripting

Date validity check

hi All, i have file in which it has 2000 records like, test.txt ==== 2011-03-01 2011-03-01 2011-03-01 2011-03-01 2011-03-01 2011-03-02 2011/03/02 previously i used for loop to find the date check like below, for i in `cat test.txt` do d=`echo $i | cut -c9-10| sed 's/^0*//'`;... (11 Replies)
Discussion started by: mechvijays
11 Replies

3. Shell Programming and Scripting

finding date numeral from file and check the validity of date format

hi there I have file names in different format as below triss_20111117_fxcb.csv triss_fxcb_20111117.csv xpnl_hypo_reu_miplvdone_11172011.csv xpnl_hypo_reu_miplvdone_11-17-2011.csv xpnl_hypo_reu_miplvdone_20111117.csv xpnl_hypo_reu_miplvdone_20111117xfb.csv... (10 Replies)
Discussion started by: manas_ranjan
10 Replies

4. Shell Programming and Scripting

Script to check the validity of password

Hi, I have to validate the passwords for 100s of unix users across several servers. I have the list of unix users and servers with passwrods. How can I check whether a password is correct or not using a single shell script? Note : I do not have root privileges on any server. All the... (1 Reply)
Discussion started by: Pupil
1 Replies

5. Shell Programming and Scripting

checking for command output validity

hi, i'm trying to write a script to check if the home directories of users are set correctly. below is an extract of the script here, i am trying to put the name of the owner of the home directory into the variable dirperm (by reading lines in /etc/passwd). however, it seems that when the... (1 Reply)
Discussion started by: roddo90
1 Replies
Login or Register to Ask a Question