Sponsored Content
Top Forums Shell Programming and Scripting Help with parsing data with awk , eliminating unwanted data Post 302751433 by itkamaraj on Friday 4th of January 2013 02:33:05 AM
Old 01-04-2013
Code:
 $ nawk '/VG Name/{v=$NF}/PE Size/{ps=$NF}/Free PE/{fp=$NF}fp{print v,ps,fp;fp="";}' input.txt
/dev/vg00 8 2036
/dev/vg01 8 20366
/dev/vg02 8 203645
/dev/vg03 8 2036890

if you dont have nawk, then use awk
This User Gave Thanks to itkamaraj For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Parsing XML dynamic data via awk?

I am trying to use a line of output in an XML file as input in another new XML file for processing purposes via a shell script. Since I am a newbie though, I'm not sure how to do this since the data is different everytime. I am using this technique with static data right now: echo -n "Running... (5 Replies)
Discussion started by: corwin43
5 Replies

2. Shell Programming and Scripting

Remove unwanted data?

Hi Can any one help me remove the unwanted data? I would want to remove the complete event id 4910 ( the type there is INFO), that means, I have to remove starting from 7th - 19th lines. can any one of you please help? Thanks, (24 Replies)
Discussion started by: hitmansilentass
24 Replies

3. Shell Programming and Scripting

Eliminate unwanted data

Hi, I am stuck on writing a script that reads a file, retains wanted data but discards unwanted data from a CSV file. This is a sample of my table {not the actual data) ID Color tel_num Name color2 color3 abcdef green 5551212 jj88 red blue acbdfe yellow... (5 Replies)
Discussion started by: t524ube
5 Replies

4. Shell Programming and Scripting

Question about Awk for Data Parsing

Hi, I am doing some data parsing for some economics research. I was recently exposed to shell script and am brand new to awk. I have a large csv file (like 10G) and I would like to make it a lot smaller with awk, but it is a bit tricky for me and I haven't been able to get it yet. I would... (5 Replies)
Discussion started by: EconResearch
5 Replies

5. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

6. Shell Programming and Scripting

Help in Parsing data

I have below string Transaction_ID:SDP-DM-151204679 , Transaction_DateTime:2011-02-11 00:00:15 GMT+05:30 , Transaction_Mode:WAP , Circle_ID:4 , Circle_Name:BJ ,Zone: , CustomerID:B_31563486 , MSISDN:7870904329 , IMSI:405876122068099 , IMEI: , Sub_Profile:Pre-Paid , CPID:Nazara , CPNAME:Nazara ,... (6 Replies)
Discussion started by: poweroflinux
6 Replies

7. UNIX for Dummies Questions & Answers

Deleting the unwanted data based on condition

hi i have my input data like this aaa bbb ccc asa dff nmj mnj saa dff oik aax cdx saa oik asq sdf dssi want my output file to be like this mnj saa dff oik aax cdx saa oiki want to retain only those lines which will have oik just below them and i want oik to be as next column to those... (1 Reply)
Discussion started by: anurupa777
1 Replies

8. Shell Programming and Scripting

Parsing cron data with awk

Heya, I'm currently working on a script so I can see which cron jobs, if any, on a system are executing less frequently than 15 minutes (1 - 14 minutes). This is the only data I'm interested in. So far I have the following: #!/bin/bash IFS=$'\n';for line in `ls -f /var/spool/cron/*`; do... (5 Replies)
Discussion started by: Elvirnith
5 Replies

9. Shell Programming and Scripting

Parsing XML (and insert data) then output data (bash / Solaris)

Hi folks I have a script I wrote that basically parses a bunch of config and xml files works out were to add in the new content then spits out the data into a new file. It all works - apart from the xml and config file format in the new file with XML files the original XML (that ends up in... (2 Replies)
Discussion started by: dfinch
2 Replies

10. Shell Programming and Scripting

awk --> math-operation in data-record and joining with second file data

Hi! I have a pretty complex job - at least for me! i have two csv-files with meassurement-data: fileA ...... (2 Replies)
Discussion started by: IMPe
2 Replies
LVM(3pm)						User Contributed Perl Documentation						  LVM(3pm)

NAME
Linux::LVM - Perl extension for accessing Logical Volume Manager(LVM) data structures on Linux. SYNOPSIS
use Linux::LVM; Linux::LVM->units('G'); ABSTRACT
The live data used in the examples is included in the DESCRIPTION area for your convenience and reference. DESCRIPTION
units() Get or set the units used to report sizes of LVs, PVs, etc. legal values: hbskmgtpeHBSKMGTPE see man lvm documentation of --units get_volume_group_list() This routine will return an array that contains the names of the volume groups. @vgs = get_volume_group_list(); print "@vgs "; Would yield the following: vg00 get_volume_group_information($) This routine will return all of the volume group information about the specified volume group. %vg = get_volume_group_information("vg00"); foreach(sort keys %vg) { print "$_ = $vg{$_} "; } Would yield the following: access = read/write act_pv = 2 alloc_pe = 3840 alloc_pe_size = 15 alloc_pe_size_unit = GB cur_lv = 3 cur_pv = 2 free_pe = 864 free_pe_size = 3.38 free_pe_size_unit = GB max_lv = 256 max_lv_size = 255.99 max_lv_size_unit = GB max_pv = 256 open_lv = 0 pe_size = 4 pe_size_unit = MB status = available/resizable total_pe = 4704 uuid = BBq8si-NyRR-9ZNW-3J5e-DoRO-RBHK-ckrszi vg_number = 0 vg_size = 18.38 vg_size_unit = GB vgname = vg00 get_logical_volume_information($) This routine will return all of the logical volume information associated with the specified volume group. %lv = get_logical_volume_information("vg00"); foreach $lvname (sort keys %lv) { foreach(sort keys %{$lv{$lvname}}) { print "$_ = $lv{$lvname}->{$_} "; } print " "; } Would yield the following results: alloc_le = 1024 allocation = next free cur_le = 1024 device = 58:0 lv_number = 1 lv_size = 4 lv_size_unit = GB name = /dev/vg00/lvol1 open_lv = 0 read_ahead = 1024 status = available write_access = read/write alloc_le = 1280 allocation = next free cur_le = 1280 device = 58:1 lv_number = 2 lv_size = 5 lv_size_unit = GB name = /dev/vg00/lvol2 open_lv = 0 read_ahead = 1024 status = available write_access = read/write alloc_le = 1536 allocation = next free cur_le = 1536 device = 58:2 lv_number = 3 lv_size = 6 lv_size_unit = GB name = /dev/vg00/lvol3 open_lv = 0 read_ahead = 1024 status = available write_access = read/write get_physical_volume_information($) This routine will return all of the information information about the physical volumes assigned to the specified volume group. %pv = get_physical_volume_information("vg00"); foreach $pvname (sort keys %pv) { foreach(sort keys %{$pv{$pvname}}) { print "$_ = $pv{$pvname}->{$_} "; } print " "; } Would yield the following results: device = /dev/hda3 free_pe = 0 pv_number = 1 status = available / allocatable total_pe = 2160 device = /dev/hda4 free_pe = 864 pv_number = 2 status = available / allocatable total_pe = 2544 get_lv_info($) This routine will return all of the information about the specified logical volume. The information will be returned in a hash. get_lv_info %lv = get_lv_info("/dev/vg00/lvol1"); foreach (sort keys %lv) { print "$_ = $lv{$_} "; } Would yield the following results: access = read/write alloc_le = 1024 allocation = next free block_device = 58:0 current_le = 1024 lv_name = /dev/vg00/lvol1 lv_number = 1 lv_open = 0 read_ahead = 1024 size = 4 size_unit = GB status = available vg_name = vg00 get_pv_info($) This routine will return all of the information about the specified physical volume. The information will be returned in a hash. %pv = get_pv_info("/dev/hda3"); foreach (sort keys %pv) { print "$_ = $pv{$_} "; } Would yield the following results: alloc_pe = 2160 allocatable = yes (but full) free_pe = 0 num_lvols = 2 pe_size = 4096 pe_size_unit = KByte pv_name = /dev/hda3 pv_number = 1 sectors = 17703630 size = 8.44 size_info = NOT usable 4.19 MB [LVM: 136 KB] size_unit = GB status = available total_pe = 2160 uuid = 2c5ADu-oEdt-ovCe-rqp0-MWpF-I5u1-8XigH4 vg_name = vg00 Command Output Used In The Above Examples: /sbin/vgdisplay -v --- Volume group --- VG Name vg00 VG Access read/write VG Status available/resizable VG # 0 MAX LV 256 Cur LV 3 Open LV 0 MAX LV Size 255.99 GB Max PV 256 Cur PV 2 Act PV 2 VG Size 18.38 GB PE Size 4 MB Total PE 4704 Alloc PE / Size 3840 / 15 GB Free PE / Size 864 / 3.38 GB VG UUID BBq8si-NyRR-9ZNW-3J5e-DoRO-RBHK-ckrszi --- Logical volume --- LV Name /dev/vg00/lvol1 VG Name vg00 LV Write Access read/write LV Status available LV # 1 # open 0 LV Size 4 GB Current LE 1024 Allocated LE 1024 Allocation next free Read ahead sectors 1024 Block device 58:0 --- Logical volume --- LV Name /dev/vg00/lvol2 VG Name vg00 LV Write Access read/write LV Status available LV # 2 # open 0 LV Size 5 GB Current LE 1280 Allocated LE 1280 Allocation next free Read ahead sectors 1024 Block device 58:1 --- Logical volume --- LV Name /dev/vg00/lvol3 VG Name vg00 LV Write Access read/write LV Status available LV # 3 # open 0 LV Size 6 GB Current LE 1536 Allocated LE 1536 Allocation next free Read ahead sectors 1024 Block device 58:2 --- Physical volumes --- PV Name (#) /dev/hda3(1) PV Status available / allocatable Total PE / Free PE 2160 / 0 PV Name (#) /dev/hda4(2) PV Status available / allocatable Total PE / Free PE 2544 / 864 SEE ALSO
vgdisplay(1M) lvdisplay(1M) pvdisplay(1M) AUTHOR
Chad Kerner, <chadkerner@yahoo.com> COPYRIGHT AND LICENSE
Copyright 2003 by Chad Kerner This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-02-11 LVM(3pm)
All times are GMT -4. The time now is 05:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy