![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ftp checking | ust | Shell Programming and Scripting | 0 | 07-10-2008 03:30 AM |
| Ksh Checking if string has 2 characters and does not contain digits? | developncode | UNIX for Dummies Questions & Answers | 1 | 04-08-2008 04:19 PM |
| EOF checking the below | ramkrix | High Level Programming | 10 | 03-11-2008 01:43 AM |
| Checking for PXE | maestro@altiris | SUN Solaris | 5 | 05-25-2004 01:06 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
That shell script above - you see where it displays "error" - if you make the script in a file with the execute bit set, you can run it. Use the portion that shows an error, i.e. "Skipping line" - and say, for example, "exit 1". Then at the end, assuming it didn't hit there, say "exit 0". Remove the printing where it's OK on A/B. Then your script exit value is zero/non-zero and you can use it as a test. Have it's input be from standard input, and it can "filter" for you. I realize this might be lots of theory and not enough specifics. If so, I could make it so and give you exact examples. Other folks here could too, I imagine. If you need it and no one has by the time I get back here, I'll do it.
|
|
||||
|
Thanks for all the above help, but let me clarify the need of what is required to see if anyone can assist further.
Currently as stated i have teh following file called TEST1.CSV ID ,, VALUE A001 ,, 100 B002 ,, 200 A004 ,, 300 B006 ,, 100 A997 ,, 200 B776 ,, 400 This file needs to be processed but only if all the ID's are correct (that means only if the IDs begin with an A - B charcter. If the ID begins with any character other A or B the process needs to exit out the script with error message. What i would like is the following: IF [begining of row is not A or B] THEN print error message exit 1 END IF No else required as if the only A and B the IF statement will end succesfully leading the process scripting afterwards. So any thoughts, not really as complex as previously thought??? |
|
||||
|
SAMZ, until now you didn't tell us what you really want to achieve. The logic you used is ok, but - depending on what you want to do, the part inside "carry on doing what you want" - there may or may not be better solutions. We are able to help you only if we know exactly what you want to achieve.
Maybe your way (that is: to do it in shell script language) is good, because the shell is best suited to what you want to achieve. The other solutions (awk, sed, ...) may or may not be better suited than your solution because the respective tools may or may not be better suited to what you want to do - to finally assess this question we would need to know what you want to do. I hope this helps. bakunin |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|