![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Deleting Characters at specific position in a line if the line is certain length | Cailet | Shell Programming and Scripting | 10 | 12-17-2008 02:41 PM |
| Length of each line. | senthil_is | Shell Programming and Scripting | 7 | 08-28-2008 09:18 AM |
| line length | Sreejith_VK | Shell Programming and Scripting | 4 | 03-10-2008 10:46 AM |
| AWK - Line length validation | en7smb | Shell Programming and Scripting | 3 | 05-09-2007 12:04 PM |
| Command line inputs validation | sendhilmani123 | Shell Programming and Scripting | 2 | 05-29-2006 07:50 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
AWK - Line length validation
Hi, I have requirement where record length is stored in an variable RECORD_LENGTH Code goes as follows Code:
RECORD_LENGTH=537
the above is arrived from
#RECORD_LENGTH=`awk -F"=" '{$sum+=$2} END{print $sum}' DBP_Claims_CFG.ini`
awk '
{
if (length() == '$RECORD_LENGTH')
print FNR, $0 > "valid.file";
else
print FNR, $0> "invalid.file"
} ' test_file.dat
the above code does not work. if i try manually like Code:
awk '
{
if (length() == 537)
print FNR, $0 > "valid.file";
else
print FNR, $0> "invalid.file"
} ' test_file.dat
code works perfectly. need to work with variable storing the record length of a file. your help is appreciated. Last edited by vgersh99; 09-29-2009 at 11:41 AM.. Reason: code tags, PLEASE! |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|