![]() |
|
|
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 |
| Unix File Validation! Help | minnuverma | Shell Programming and Scripting | 8 | 10-24-2008 08:46 AM |
| validation required in unix | u263066 | UNIX for Dummies Questions & Answers | 2 | 09-25-2008 04:37 AM |
| UNIX script Validation | matchey | Shell Programming and Scripting | 1 | 05-07-2008 12:56 PM |
| How Can I Do Time Validation in UNIX | mosammey | UNIX for Dummies Questions & Answers | 4 | 11-26-2007 12:02 PM |
| Time Validation in UNIX? | mosammey | Shell Programming and Scripting | 1 | 11-21-2007 02:23 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Unix File Validation! Help
Hi All,
I got a file with 3 fields delimited by hyphen "-". I have to validate & cleanse the data before i begine the processing Requirements 1. No record should contain more than 2 delimiters 2. No record should even contain less than 2 delimiters 3. Any records that matches rule 1 & 2 should be captured to bad_records.dat 4. Delete records satisfying rules 1 & 2 from original incoming data file Sample Format input.dat COL1-COL2-COL3 scott-2000-10 tiger-1000-20 c-bill-1000-30 mike20-1000 so after the validation&cleansing process, the data should appear like below input.dat scott-2000-10 tiger-1000-20 bad_records.dat c-bill-1000-30 mike20-1000 Please note i can't use perl progressive scanning. I need to achieve this via korn shell script Thanks guys |
|
||||
|
Code:
for inputfile in *.dat
do
awk ' {good=sprintf("%s.%s", FILENAME, "good")
bad=sprintf("%s.%s", FILENAME, "bad")
if(NF==3) { print $0 > good} else {print $0 >bad}}' $inputfile
done
you can add what you need to this liitle code fragment. |
![]() |
| Bookmarks |
| Tags |
| minnu, unix file validation |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|