Sponsored Content
Top Forums UNIX for Beginners Questions & Answers awk to convert CSV into colums Post 303044330 by drysdalk on Wednesday 19th of February 2020 11:05:08 AM
Old 02-19-2020
Hi,

If you're wanting to print the separate fields of a CSV out one per line, then something like this would work:

Code:
$ cat test.csv
HiringManager_RHMC,DirectSupervisor_RHMC,ProcessServerReadAccess_ST
$ awk -F, '{print $1"\n"$2"\n"$3}' < test.csv      
HiringManager_RHMC
DirectSupervisor_RHMC
ProcessServerReadAccess_ST
$

Hope this helps - if it doesn't quite work for you then if you can let us know what doesn't work I'm sure we can help further.
This User Gave Thanks to drysdalk For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

convert this into csv using awk/shell script

Hi Scripting gurus, I need to convert following text snippet into csv. please help Input heading1 = data1 heading2 = data2 .. .. heading n = data n heading 1 = data1 .. .. Output data1,data2,....,data n (3 Replies)
Discussion started by: azs0309
3 Replies

2. Shell Programming and Scripting

Compare two csv files by two colums and create third file combining data from them.

I've got two large csv text table files with different number of columns each. I have to compare them based on first two columns and create resulting file that would in case of matched first two columns include all values from first one and all values (except first two colums) from second one. I... (5 Replies)
Discussion started by: agb2008
5 Replies

3. Shell Programming and Scripting

Awk script to convert csv to html

Hi Written some script to convert csv to html but could not add table headers.Below are the errors iam getting ./csv2html | more + awk -v border=1 -v width=10 -v bgcolor=black -v fgcolor=white BEGIN { printf("<table border=\"%d\" bordercolor=\"%s\" width=\"%d\"... (2 Replies)
Discussion started by: zeebala1981
2 Replies

4. Programming

awk script to convert a text file into csv format

hi...... thanks for allowing me to start a discussion i am collecting usb usage details of all users and convert it into csv files so that i can export it into some database.. the input text file is as follows:- USB History Dump by nabiy (c)2008 (1) --- Kingston DataTraveler 130 USB... (2 Replies)
Discussion started by: certteam
2 Replies

5. Shell Programming and Scripting

awk convert xml to csv

Hi, I have an xml file and I want to convert it with awk in to a csv file Test.xml <Worksheet ss:Name="Map1"> <Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="2" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="60"> <Row> <Cell><Data... (6 Replies)
Discussion started by: research3
6 Replies

6. Solaris

awk - Print variable number of colums from a starting column

Hi guys, I usualy am able to google awk stuff but I can't find it so far and there are so many awking gurus here that I will give it a shot. I want to print $1;$3;"$5 up to the $NF". In other words, I can have 1000 colums, but need to have $5 up to the end. I started with the idea of... (2 Replies)
Discussion started by: plmachiavel
2 Replies

7. Shell Programming and Scripting

Help on convert rows to colums

Need help to convert the following data Account name: admin Role: admin Description: Administrator Enabled: Yes to Account Name Role Description Enabled admin admin Administrator Yes Perl or AWK? Thanks San (9 Replies)
Discussion started by: sanguy
9 Replies

8. Shell Programming and Scripting

Awk to convert a text file to CSV file with some string manipulation

Hi , I have a simple text file with contents as below: 12345678900 971,76 4234560890 22345678900 5971,72 5234560990 32345678900 71,12 6234560190 the new csv-file should be like: Column1;Column2;Column3;Column4;Column5 123456;78900;971,76;423456;0890... (9 Replies)
Discussion started by: FreddyDaKing
9 Replies

9. Shell Programming and Scripting

Convert XML to CSV using awk or shell script

Hello, I am working on a part of code where I need a awk or shell script to convert the given XML file to CSV or TXT file. There are multiple xml files and of different structure, so a single script is required for converting data. I did find a lot of solutions in the forum but... (16 Replies)
Discussion started by: Rashmitha
16 Replies

10. UNIX for Dummies Questions & Answers

awk on multiple colums

HI, I need to filter my data based on 3 different columns. Two of the columns are unique so it worked if u use something like grep 'PASS.*HIGH|HIGH.*PASS' file.tsv However the other column is not unique .. So basically I want to extract out lines that match only match these 3... (4 Replies)
Discussion started by: janshamsani
4 Replies
virt-df(1)						      Virtualization Support							virt-df(1)

NAME
virt-df - Display free space on virtual filesystems SYNOPSIS
virt-df [--options] virt-df [--options] -d domname virt-df [--options] -a disk.img [-a disk.img ...] Old style: virt-df [--options] domname virt-df [--options] disk.img [disk.img ...] DESCRIPTION
"virt-df" is a command line tool to display free space on virtual machine filesystems. Unlike other tools, it doesn't just display the size of disk allocated to a virtual machine, but can look inside disk images to see how much space is really being used. If used without any -a or -d arguments, "virt-df" checks with libvirt to get a list of all active and inactive guests, and performs a "df"-type operation on each one in turn, printing out the results. If any -a or -d arguments are specified, "virt-df" performs a "df"-type operation on either the single named libvirt domain, or on the disk image(s) listed on the command line (which must all belong to a single VM). In this mode (with arguments), "virt-df" will only work for a single guest. If you want to run on multiple guests, then you have to invoke "virt-df" multiple times. Use the --csv option to get a format which can be easily parsed by other programs. Other options are similar to the standard df(1) command. EXAMPLES
Show disk usage for a single libvirt guest called "F14x64". Make the output human-readable: # virt-df -d F14x64 -h Filesystem Size Used Available Use% F14x64:/dev/sda1 484M 66M 393M 14% F14x64:/dev/vg_f13x64/lv_root 7.4G 3.4G 4.0G 46% Show disk usage for a disk image file called "test.img": $ virt-df -a test1.img Filesystem 1K-blocks Used Available Use% test1.img:/dev/sda1 99099 1551 92432 2% OPTIONS
--help Display brief help. -a file --add file Add file which should be a disk image from a virtual machine. If the virtual machine has multiple block devices, you must supply all of them with separate -a options. The format of the disk image is auto-detected. To override this and force a particular format use the --format=.. option. -c URI --connect URI If using libvirt, connect to the given URI. If omitted, then we connect to the default libvirt hypervisor. If you specify guest block devices directly (-a), then libvirt is not used at all. --csv Write out the results in CSV format (comma-separated values). This format can be imported easily into databases and spreadsheets, but read "NOTE ABOUT CSV FORMAT" below. -d guest --domain guest Add all the disks from the named libvirt guest. Domain UUIDs can be used instead of names. --format=raw|qcow2|.. --format The default for the -a option is to auto-detect the format of the disk image. Using this forces the disk format for -a options which follow on the command line. Using --format with no argument switches back to auto-detection for subsequent -a options. For example: virt-df --format=raw -a disk.img forces raw format (no auto-detection) for "disk.img". virt-df --format=raw -a disk.img --format -a another.img forces raw format (no auto-detection) for "disk.img" and reverts to auto-detection for "another.img". If you have untrusted raw-format guest disk images, you should use this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). -h --human-readable Print sizes in human-readable format. You are not allowed to use -h and --csv at the same time. -i --inodes Print inodes instead of blocks. --one-per-guest Run one libguestfs appliance per guest. Normally "virt-df" will add the disks from several guests to a single libguestfs appliance. You might use this option in the following circumstances: o If you think an untrusted guest might actively try to exploit the libguestfs appliance kernel, then this prevents one guest from interfering with the stats printed for another guest. o If the kernel has a bug which stops it from accessing a filesystem in one guest (see for example RHBZ#635373) then this allows libguestfs to continue and report stats for further guests. --uuid Print UUIDs instead of names. This is useful for following a guest even when the guest is migrated or renamed, or when two guests happen to have the same name. Note that only domains that we fetch from libvirt come with UUIDs. For disk images, we still print the disk image name even when this option is specified. -v --verbose Enable verbose messages for debugging. -V --version Display version number and exit. -x Enable tracing of libguestfs API calls. STATVFS NUMBERS
"virt-df" (and df(1)) get information by issuing a statvfs(3) system call. You can get the same information directly, either from the host (using libguestfs) or inside the guest: From the host Run this command: guestfish --ro -d GuestName -i statvfs / (change "/" to see stats for other filesystems). From inside the guest Run this command: python -c 'import os; s = os.statvfs ("/"); print s' (change "/" to see stats for other filesystems). NOTE ABOUT CSV FORMAT
Comma-separated values (CSV) is a deceptive format. It seems like it should be easy to parse, but it is definitely not easy to parse. Myth: Just split fields at commas. Reality: This does not work reliably. This example has two columns: "foo,bar",baz Myth: Read the file one line at a time. Reality: This does not work reliably. This example has one row: "foo bar",baz For shell scripts, use "csvtool" (<http://merjis.com/developers/csv> also packaged in major Linux distributions). For other languages, use a CSV processing library (eg. "Text::CSV" for Perl or Python's built-in csv library). Most spreadsheets and databases can import CSV directly. SHELL QUOTING
Libvirt guest names can contain arbitrary characters, some of which have meaning to the shell such as "#" and space. You may need to quote or escape these characters on the command line. See the shell manual page sh(1) for details. EXIT STATUS
This program returns 0 if successful, or non-zero if there was an error. SEE ALSO
df(1), guestfs(3), guestfish(1), virt-filesystems(1), <http://libguestfs.org/>. AUTHOR
Richard W.M. Jones <http://people.redhat.com/~rjones/> COPYRIGHT
Copyright (C) 2009-2012 Red Hat Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. libguestfs-1.18.1 2013-12-07 virt-df(1)
All times are GMT -4. The time now is 08:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy