Create csv from four disparate files

Login or Register to Reply

Thread Tools Search this Thread
# 8  
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

This User Gave Thanks to RudiC For This Post:
# 9  
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
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
Shell Programming and Scripting
How to create or convert to pdf files from csv files using shell script?
Hi, Can anyone help me how to convert a .csv file to a .pdf file using shell script Thanks... Shell Programming and Scripting
Shell Programming and Scripting
How to create a .csv file from 2 different .txt files?
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
UNIX for Dummies Questions & Answers
How to create a CSV File by reading fields from separate files
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
Shell Programming and Scripting
Merging files to create CSV file
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
Shell Programming and Scripting
Red Hat Linux

Red Hat, Inc. is a global American software company providing open-source software products to the enterprise community. Red Hat was Founded in 1993, and has its corporate headquarters in Raleigh, North Carolina, with other offices worldwide. On October 28, 2018, IBM announced its intent to acquire Red Hat for $34 billion. Red Hat has focused on Red Hat Enterprise Linux an enterprise operating system. Red Hat also acquired the open-source enterprise middleware vendor JBoss. Red Hat also sells an enterprise virtualization product, Red Hat Virtualization (RHV). Red Hat also provides storage, operating system platforms, middleware, applications, management products, and support, training, and consulting services. Red Hat actively creates, maintains, and contributes to many free and open software projects. Red Hat has acquired several proprietary software products through corporate mergers and acquisitions and has released these software acquisitions under open-source licenses.
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.