Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Working on a ksh script. Trying to run through a set of files, and return a set of files, which are unique subsets by column.
Code
...
__files=`ls $__PathData/*_full.txt`
echo $files
typeset -Z2 cnt=0
for fil in $__files ; do
let cnt=$cnt+1;
echo $fil;
echo $cnt;
nohup awk -F'|' '{val=$2"|"$3"|"$4; if(!(val in arr)){arr[val]=1;print val}}' $fil > $__PathData/dim_cli"$cnt.txt" &; _pid=$_pid" "$!;
doneOUTPUT on nohup:
$ more nohup.out
Tue Nov 25 05:39:35 EST 2008
...
./cdtstdload.sh[27]: 0403-057 Syntax error at line 37 : `done' is not expected.
nohup.out: ENDI've tried adding semicolons among other things, same error.
Tips?
Joe
All Your Base Are Belong to Us

First, why don't you get the awk script working before you nohup it and create output? Get this working first:
awk -F'|' '{val=$2"|"$3"|"$4; if(!(val in arr)){arr[val]=1;print val}}' $fil
Second, your for statement will break unless $fil is always one record - no white space.
Third, what are you trying to do with the awk statement? This does not make sense to me:
if(!(val in arr)){arr[val]=1;print val
what is the significance of 'print val' and setting the array?
I think you are trying to ignore duplicates, but it doesn make any difference because the array value is always set to 1.
Fourth, how about showing a sample of your data?

The awk did work fine, that wasn't the issue.
Tested, and the section of the line
__pid=$__pid" "$!;
was causing the error.Broke it out into another line, and now it works fine.
Thanks
Joe
All Your Base Are Belong to Us

![]() |
![]() |
![]() |

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