Create csv from four disparate files


Login or Register to Reply

 
Thread Tools Search this Thread
# 8  
Code:
for FN in *.out                                 # cycle through ALL *.out files (you could narrow it down somewhat by using *account.out)
  do    H=${FN%%.*}                             # use "parameter expansion" to remove everything beyond first
                                                #   dot (= beyond "host_n") and assign to H
        if [ ! "$H" = "$OH" ]                   # check if new host_n (different from old H)
          then  OH=$H                           # save new $H into old H, and
                {
                echo "host,accounts,max,pwd,standard"                   # print header
                echo $H | paste -d, - $H*.out | sed 's/, \+/,/'         # create csv fields / lines 

                } > $H.result                   # save all output to result file
        fi
  done

This User Gave Thanks to RudiC For This Post:
# 9  
RudiC,
Thank you.
My head was failing at using a new variable within the if statement.
I've a lot learn when it comes to this stuff.

Most of the time I smash on something, poke about this and other sites until I come up with something that works.
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Compare 2 files of csv file and match column data and create a new csv file of them
refrain
Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07...... Shell Programming and Scripting
8
Shell Programming and Scripting
How to create or convert to pdf files from csv files using shell script?
ssk250
Hi, Can anyone help me how to convert a .csv file to a .pdf file using shell script Thanks... Shell Programming and Scripting
2
Shell Programming and Scripting
How to create a .csv file from 2 different .txt files?
alisrpp
Hi, I need to create a .csv file from information that i have in two different tab delimited .txt file. I just want to select some of the columns of each .txt file and paste them into a .cvs file. My files look like: File 1 transcript_id Seq. Description Seq. Length ...... UNIX for Dummies Questions & Answers
2
UNIX for Dummies Questions & Answers
How to create a CSV File by reading fields from separate files
mayanksargoch
SHELL SCRIPT Hi, I have 3 separate files within a folder. Every File contains data in a single column like File1 contains data mayank sushant dheeraj File2 contains DSA_AT MG_AT FLAT_09 File3 contains data 123123 232323... Shell Programming and Scripting
2
Shell Programming and Scripting
Merging files to create CSV file
Ravendark
Hi, I have different files of the same type, as: Time: 100 snr: 88 perf: 10 other: 222 Each of these files are created periodically. What I need to do is to merge all of them into one but having the following form:... Shell Programming and Scripting
2
Shell Programming and Scripting
Man Pages

Unix did not exist in the first two years of Unix history. The first actual unix man pages were written by Dennis Ritchie and Ken Thompson at the direction of Doug McIlroy in 1971. The Unix Programmer's Manual was first published on November 3, 1971. The Unix Programmer's Manual also contained a set of short papers describing of operating system features. The printed version of the Unix Programmer's manual was originally contained in a single binder. As of PWB/UNIX and the 7th Edition of Research Unix these documents were split into two volumes with the printed man pages forming Volume 1. Later versions of the Unix documentation followed the concise style of the early man pages. Dennis Ritchie added a "How to get started" section to the Third Edition introduction. Lorinda Cherry provided the "Purple Card" pocket reference for the Sixth and Seventh Editions. For the Fourth Edition the man pages were formatted using the troff typesetting package and its set of -man macros. These macros were completely revised between the Sixth and Seventh Editions of the Unix Programmer's Manual and have not changed much since the "good ole' days".
In the early days of Unix the availability of online documentation through a man page system was regarded as a great advance in computing. The modern descendants of 4.4BSD also distributed man pages as system documentation. Virtually every Unix command line application comes with a man page and many Unix users perceive a command's lack of a man page as a sign of low quality. Debian, for example, has written man pages for numerous programs which originally had no man page.
Please enjoy and help our forum community by "showing your work" and posting your code, even when your code is not working as expected. To help others help you, please wrap your code blocks, sample input, sample output, error messages, and other data in CODE tags and wrap your short commands and short data objects in ICODE tags. We were all beginners in the beginning. If you have any questions about how to register or how to post, please contact us in Live Chat. Thank you and enjoy this "forever free" technical support community for UNIX, Linux and computer information technology in general.