![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| To generate the FTP Script file | konankir | Shell Programming and Scripting | 1 | 04-01-2008 04:16 PM |
| Script to generate text file from excel file | isingh786 | UNIX for Dummies Questions & Answers | 1 | 01-24-2008 10:32 AM |
| generate new string from a text file | walterwaston | Shell Programming and Scripting | 6 | 10-16-2007 04:43 PM |
| generate file incremented by 1 | mape | Shell Programming and Scripting | 4 | 08-17-2006 04:46 AM |
| How to generate an image file from FD | Esteban | UNIX for Advanced & Expert Users | 1 | 12-22-2005 11:50 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I have a file which has some thousand records in the following format
File: input.txt -> <option value="14333">VISWANADH VELAMURI</option> <option value="17020">VISWANADHA RAMA KRISHNA</option> I want to generate a csv file from the above file as follows File: output.txt -> 14333,VISWANADH VELAMURI 17020,VISWANADHA RAMA KRISHNA The HTML option tags are to be removed alongwith the unwanted tabs and the empty lines in between. I have tried cut, awk, but I am not getting the correct combination. Can you please help me out, as I want to upload this data into a database table. Thanks. |
|
||||
|
Code:
#! /opt/third-party/bin/perl
open (FILE, "< $ARGV[0] ") || die "Unable to open $ARGV[0] <$!> \n";
my(@split_fields, @second_split, @further);
while( chomp($_ = <FILE> ) ) {
@split_fields = split(/"/, $_);
@second_split = split(/>/, $_);
@further = split(/</, $second_split[1]);
print "$split_fields[1],$further[0]\n";
}
close(FILE);
exit 0
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|