Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a file with same length lines (300 chars each) and need to check one digit (if !=0) and process it(to append to a seperate file). I used cut command to extract required columns and paste them in another file.But I cannot compare the 49th caracter (a digit) without buffering a line. How do I define an array in ksh?
Appreciate If you could suggest any other alternative method.

awk is good for that, and you do not need to send the original file through the cut process first. Following code will select the lines that do not have a zero in column 49 and will append portions of that line to an output file:
awk 'substr($0,49,1)!=0 {\
print substr($0,1,10) substr($0,55,7)
}' infile >> outfileIf the fields of infile are clearly delimited with something (white space, commas, whatever), then the awk code can refer to those fields as $1, $2, etc instead of using substring function.

![]() |
Lost my windows 2000 pass...
|
Root password
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |