Whats wrong with this line?

I have a file $I_FILE that I need to filter and store the 1st and the 9th columns in another file $O_FILE.
With this in Perl,

system ("awk -F, '{print \$1, \$9}' \$I_FILE | sed '\/^\$\/d' > O_FILE");

I get:
4096045055

The first line in I_FILE is:
4294967295,0,3,2103159,54668771,54668771,0,3233,566547,28,18,12

so it should print:
4294967295 566547
in o_file.

Thanks!

sorry this:
*****
I get:
4096045055

*****

was from another stray print command, irrelevant here.

I cannot re-create, nor imagine, where your output is coming from. Can you make a one-line copy of I_FILE and run against that?
Also, unclear what you are trying to accomplish with your sed command.

#! /usr/bin/perl
system ("awk -F, '{print \$1,\$9}' I_FILE");
exit
> extr_flds 
4294967295 566547
 

$I_FILE="ifile";
where ifile looks like this
4294967295,0,3,2103159,54668771,54668771,0,1,566547,8770,0,384,228,18,12
4294967295,0,4,2103160,54668772,54668772,0,1,566548,8770,0,384,228,18,12
4294967295,1,0,2103161,54668773,54668773,0,3,566549,8770,0,384,228,18,12
4294967295,2,0,2103162,54668774,54668774,0,5,566550,8770,0,384,228,18,12

I need to filter out the first and the ninth column:
4294967295 566547
4294967295 566548
4294967295 566549
4294967295 566550

hence:
system ("awk -F, '{print \$1, \$9}' \$I_FILE | sed '\/^\$\/d' > O_FILE")

I dont *have* to use awk/sed. If there is a simpler way with Perl, that would work too.
Thanks!

cat I_FILE | cut -d"," -f1,9

or, if you must remain in perl...

#! /usr/bin/perl

system ("awk -F, '{print \$1,\$9}' I_FILE");

system ("cat I_FILE | cut -d',' -f1,9");
exit

both of the above inside of perl return the 1st & 9th fields.

I still do not understand the sed part - your second half of the command - what are you trying to accomplish?

Or, staying in perl and assuming I_FILE and O_FILE are already opened what's wrong with...

while (<I_FILE>){
#$_ now has contents of line
chomp $;
(@I_FIELDS) = split(","); #splits $
on comma
print O_FILE "$I_FIELDS[0] $I_FIELDS[8]\n"; # fields 1 and 9
}

OK, so there's a loop here vs a one-line system() call in the other solutions. I don't know what would perform faster... Might depend on size of I_FILE