Randall A Sindlinger on 19 Apr 2011 07:28:33 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] perl -e with system()


Hey folks,

I'm getting a weird error.

I have a tab-separated datafile of the form

audit-2.0.5-5.8.1.x86_64	/var/log/audit/audit.log
ca-certificates-1-9.1.noarch	/var/lib/ca-certificates/ca-bundle.pem
filesystem-11.4-11.14.1.x86_64	parent is /boot/	/boot/backup_mbr
filesystem-11.4-11.14.1.x86_64	parent is /etc/	/etc/.pwd.lock

I want to split the filenames up into separate files, just using the package
as the filename.

perl -n  -e '($a, $b, $c) = split("\t"); chomp $a; chomp $b; chomp $c; if ($c) {system ("echo $c >> $a")} 
else {system ("echo $b >> $a")}' < data.file

seems to do what I want, except I get a slew of errors saying

sh: -c: line 0: syntax error near unexpected token `newline'
sh: -c: line 0: `echo  >> '

Since the info got split up as I wanted, I can go on with what I'm doing,
but I'm really wondering what I'm missing that caused those errors.

Thanks,
         . o 0 ( So _this_ is why I should've gone to JP's talk )
-Randall
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug