Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Extracting some fields from a data File

Posted by perlnewuser (perlnewuser), 29 June 2004
Hi ,


I have input file like this (fields separator is "," lines separator is "\n"):


header, 06-12-2004, path, /usr/bin/sh,attribute,
100555,root,other,315,565690,
subject,bscs,sgrp,9936,6785,0 0,
return,success,0

header, 06-12-2004, path, /usr/bin/sh,attribute,100555,dba,5, subject,bscs,sgrp,9936,6785,0,return,success,0

header, 06-12-2004, path, /usr/bin/sh,
attribute,100555,tom,other,315,56,11,54,77,10,88,
subject,bscs,sgrp,9936,6785,0 0,return,success,0

I need to generate an output file like this (deleting fields between attribute and subject, please
note that number of those fields is variable):

header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0

header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0

header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0

Thanks a lot ,

CHAFIK

Posted by admin (Graham Ellis), 29 June 2004
Try

Code:
#!/usr/bin/perl -p
s/attribute.*subject/subject/;




This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho