write a perl script or kornshell reading a two files and outputting to comma format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting write a perl script or kornshell reading a two files and outputting to comma format
# 1  
Old 09-13-2009
write a perl script or kornshell reading a two files and outputting to comma format

Hello
Can someone help me to write a perl script or kornshell reading a two files and outputting to comma format.

Here is the two files
listofdisks.txt
id, diskname, diskgroup, diskisze(GB), FC
1, CN34, GRP1, 30, FC_CN34
2, CN67, GRP5, 19,
4, VD1, GRP4, 23, FC_VD1
6, CF_D1, GRP10, 23,
10, CN1, GRP4, 20, FC_CN1
11, vcD1, GRP1, 5,

second file
listofhostmappedtodisks.txt
hostname, diskname
CN12A, CN34
CN3C, VD1
CN12B, CN34
CL2, CN67
CN3A, VD1
CN3B, VD1
DF1, CF_D1
F1, CN1

The out should look like this:
OUTPUT
id, diskname hostname diskgroup diskisze(GB) FC
1, CN34, CN12A/CN12B GRP1, 30, FC_CN34
2, CN67, CL2, GRP5, 19,
4, VD1, CN3C/CN3A/CN3B, GRP4, 23, FC_VD1
6, CF_D1, DF1, GRP10, 23,
10, CN1, F1, GRP4, 20, FC_CN1
11, vcD1, GRP1, 5,

Thanks for your help in advance
Deiow
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to write in multiple output files in perl?

hi, Hope you are doing good. During my coding yesterday i got this challenge, actually not a challenge it like to optimize the code. I am printing some statement to monitor the file progress in the log file an also to display it in the screen. so i ended up in the below statements. ... (6 Replies)
Discussion started by: mad man
6 Replies

2. Programming

Date format change from mm/dd/yyyy to yyyymmdd in comma seperate line in perl

Hi All, I have line ,A,FDRM0002,12/21/2017,,0.961751583,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, it contains date in mm/dd/yyyy format i want to change this to yyyymmdd format using perl. Use code tags, thanks. (8 Replies)
Discussion started by: vishal0746
8 Replies

3. Shell Programming and Scripting

Need script for transferring bulk files from one format to text format

"Help Me" Need script for transferring bulk files from one format to text format in a unix server. Please suggest (2 Replies)
Discussion started by: Kranthi Kumar
2 Replies

4. Shell Programming and Scripting

Perl Script for reading table format data from file.

Hi, i need a perl script which reads the file, content is given below. and output in new file. TARGET DRIVE IO1 IO2 IO3 IO4 IO5 ------------ --------- --------- --------- --------- --------- 0a.1.8 266 236 ... (3 Replies)
Discussion started by: asak
3 Replies

5. Homework & Coursework Questions

Shell script calling Perl function, sort and find data, write to new files

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I must write a shell script that calls two external Perl functions--one of which sorts the data in a file, and... (6 Replies)
Discussion started by: kowit010
6 Replies

6. Shell Programming and Scripting

Perl script to parse output and print it comma separated

I need to arrange output of SQL query into a comma separated format and I'm struggling with processing the output... The output is something like this: <Attribute1 name><x amount of white spaces><Atribute value> <Attribute2 name><x amount of white spaces><Atribute value> <Attribute3... (2 Replies)
Discussion started by: Juha
2 Replies

7. Shell Programming and Scripting

Perl Script Not Reading Input Files Correctly

This is one of the strangest things that's happening to me. I'm writing a new Perl script that is trying to read a file. The file is originally in .mof format, but I also saved the contents into a .txt file. As a simple test, I wrote this: #!/user/bin/perl -w use strict; ... (3 Replies)
Discussion started by: kooshi
3 Replies

8. Shell Programming and Scripting

Reading comma separated variable into other variables in shell script

Hi, In shell script, I have a variable var = xyz, inn, day, night, calif ....n and I would like to read them in to var1 = xzy, var2 = inn, var3= day, var4 = night....var. probably in a loop. I would like to read the variables until end of the line. Comma is the delimiter and there's no comma at... (3 Replies)
Discussion started by: suryaemlinux
3 Replies

9. Shell Programming and Scripting

How to write shell script for input file name format checking?

Hello, I had written a shell script that accepts input file as cmd line argument and process this file. if ; then if ; then . $1 LOGFILE="$LOG_FILE/MIG_BIOS.log"; get_input_file else ERROR_CODE=MSCRM0005_003 error "$ERROR_CODE : Input file $1 is not available"; exit... (3 Replies)
Discussion started by: Poonamol
3 Replies

10. Shell Programming and Scripting

how to write script in compress format

i have the script how to write script in compress format in tar (1 Reply)
Discussion started by: naveeng.81
1 Replies
Login or Register to Ask a Question
MojoMojo::Formatter::File(3pm)				User Contributed Perl Documentation			    MojoMojo::Formatter::File(3pm)

NAME
MojoMojo::Formatter::File - format file as XHTML DESCRIPTION
This formatter will format the file argument as XHTML. Usage: {{file TYPE filename}} {{file Text uploads/Files/test.txt}} TYPE is a plugin present in Formatter/File/ directory. Currently there are only three: Pod, DocBook and Text The plugin TYPE format only the file which the extension match with 'can_format' method. Respectively pod, xml and txt for existing plugins. For security reasons the path of file must be include in 'whitelisting' directory. You can use path_to(DIR) to describe directory in mojomojo.conf: Just an example to view the test pod file t/var/files/test.pod : Add this to mojomojo.conf : <Formatter::Dir> prefix_url /myfiles whitelisting __path_to(t/var/files)__ </Formatter::Dir> To see the pod content formatted in xhtml, write in the text area: {{file Pod path_to(t/var/files)test.pod}} To show recursively all files of directory see script/util/dir2mojomojo.pl script. To test it: # start mojomojo ./script/mojomojo_server.pl # run dir2mojomojo script ./script/util/dir2mojomojo.pl --dir=~/dev/mojomojo/t/var/files/ --url=/myfiles Connect to http://server:3000/myfiles/ METHODS
format_content_order Format order can be 1-99. The File formatter runs on 92. format_content Calls the formatter. Takes a ref to the content as well as the context object. plugin Return the plugin to use with file attachment format Return the content formatted checkplugin Return 0 if plugin exist checkfile Directory must be include in whitelisting SEE ALSO
MojoMojo,Module::Pluggable::Ordered AUTHORS
Daniel Brosseau <dab@catapulse.org> LICENSE
This module is licensed under the same terms as Perl itself. perl v5.14.2 2010-04-07 MojoMojo::Formatter::File(3pm)