Sponsored Content
Top Forums Shell Programming and Scripting sed or awk to convert text files with recurring headings to rows and colum Post 302192450 by suresh3566 on Wednesday 7th of May 2008 01:47:18 AM
Old 05-07-2008
Quote:
Originally Posted by summer_cherry
input:
Code:
name:leo
age:28

name:stt
age:24


code:

Code:
awk 'BEGIN{FS=":";n=1}
{
if ($1=="name")
	name[n]=$2
else
{
	age[n]=$2
	n=n+1
}
}
END{
print "NAME    AGE"
for (i=1;i<=n;i++)
print name[i]"   "age[i]
}' a


output:

Code:
NAME    AGE
leo   28

stt   24

suppose if I have more than 2 fileds like name,age,total,avg then how the script changes ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get text between two special rows ?( using awk or sed)?

Hi Friends I am facing some problem in extract the lines between two fixed lines for examplemy text file look like ... -------- line 1 line 2 line 3 --------- line 4 line 5 -------- line 6 line 7 line 8 line 9 line 10 --------- now i want the data between "-------" these... (4 Replies)
Discussion started by: sushantnirwan
4 Replies

2. Shell Programming and Scripting

Using sed (or similar) to rename variable headings

Hello, I'm rather new to the world of regular expressions and sed, though am excited by its possibilities. I have a particular task I'd like to achieve, and have googled the topic quite a bit. However, having found some codes that perform a task very similar to what I'd like to do, I can't for... (2 Replies)
Discussion started by: redseventyseven
2 Replies

3. Shell Programming and Scripting

get text between two special rows ?(awk or sed)?

Hello, I've the follwing text: gfdgfg -------------------------------- dfgfdgdfg fdgfdgfdgdgf fdgf ------------------------------ f g gdgf a constant string that i know --------------------------------------------- data I want to have data I want to have data I want to have data I... (16 Replies)
Discussion started by: eric_
16 Replies

4. UNIX for Dummies Questions & Answers

joining files with different rows and colum

Hi all, I have two files: file one (9 rows, 3 columns): A 1 x1 B 2 f1 C 3 f3 D 4 u5 E 5 l9 F 6 h6 G 7 g4 H 8 r4 I 9 s2 file two (4 rows, 1 column): A B (2 Replies)
Discussion started by: anjas
2 Replies

5. UNIX for Dummies Questions & Answers

Convert rows to columns using AWK

Hi , I am struck while coding AWK script. Need your help to convert rows into columns. I should copy only those rows which are marked to Y in a file and ignore N rows. Please help me find a solution. input file 1|abc|Y 2|cdf|Y 3|efg|N 4|xyz|Y my output should be something like this... (2 Replies)
Discussion started by: rashmisb
2 Replies

6. Shell Programming and Scripting

Convert rows into columns using awk or perl

hi friends, i am able to parse cvs diff file using bit of cut and grep commands to produce following output in text file '''cvs-diff.txt''' Package-Name = dev-freetype. Old-Version = 2.4.8 New-Version = 2.4.10 Patches-removed = freetype-2.4.8-cross-compile.patch... (2 Replies)
Discussion started by: alexzander18
2 Replies

7. UNIX for Dummies Questions & Answers

Awk: convert rows to columns every n lines

Hi guys! I use AWK commands under GAMS to predispose the data files to be read by GAMS. I have a file which contains groups of data I need. Unfortunately I have the data spread in 3 rows for each subject. Here's an example (the file is really long) 1 0 2.0956 100.00 250.00 100.00 2.0956... (4 Replies)
Discussion started by: Pintug
4 Replies

8. Shell Programming and Scripting

awk or sed? rows text to co

Hello Friends! I would like to help the masters ... I have a file with the entry below and would like a script for that output: Input file: 001 1 01-20152142711532-24S 1637909825/05/2015BAHIA SERVICOS R F, ... (1 Reply)
Discussion started by: He2
1 Replies

9. Shell Programming and Scripting

Convert rows into columns and create table with awk

Hello I've four fields . They are First Name, Last Name, Age, Country. So when I run a Unix command, I get below output with these fields comes every time in different order as you can see. Some times first name is the first row and other time last name is first row in the output and etc etc..... (9 Replies)
Discussion started by: rprpr
9 Replies

10. UNIX for Beginners Questions & Answers

Help with awk or sed Command to Replace Text in Files

Hello Everyone, I have many files like so: file1.txt file2.txt file3.txt Within each file I have many lines of random text separated by commas like so: abcAAA,123,defAA,456777,ghiA,789 jklB,101,mnoBBB,11211,pqrB,13111 stuCC,415,vwxCCCC,161,yzaC,718 I am trying to use SED or AWK to... (4 Replies)
Discussion started by: D3U5X
4 Replies
AGE(4)							   BSD Kernel Interfaces Manual 						    AGE(4)

NAME
age -- Attansic/Atheros L1 Gigabit Ethernet driver SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file: device miibus device age Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): if_age_load="YES" DESCRIPTION
The age device driver provides support for Attansic/Atheros L1 PCI Express Gigabit Ethernet controllers. All LOMs supported by the age driver have TCP/UDP/IP checksum offload for both transmit and receive, TCP segmentation offload (TSO), hardware VLAN tag stripping/insertion features and an interrupt moderation mechanism as well as a 64-bit multicast hash filter. The L1 also supports Jumbo Frames (up to 10240 bytes), which can be configured via the interface MTU setting. Selecting an MTU larger than 1500 bytes with the ifconfig(8) utility configures the adapter to receive and transmit Jumbo Frames. The age driver supports the following media types: autoselect Enable autoselection of the media type and options. The user can manually override the autoselected mode by adding media options to rc.conf(5). 10baseT/UTP Set 10Mbps operation. 100baseTX Set 100Mbps (Fast Ethernet) operation. 1000baseTX Set 1000baseTX operation over twisted pair. The age driver supports the following media options: full-duplex Force full duplex operation. half-duplex Force half duplex operation. For more information on configuring this device, see ifconfig(8). HARDWARE
The age driver provides support for LOMs based on Attansic/Atheros L1 Gigabit Ethernet controller chips, including: o ASUS M2N8-VMX o ASUS M2V o ASUS M3A o ASUS P2-M2A590G o ASUS P5B-E o ASUS P5B-MX/WIFI-AP o ASUS P5B-VMSE o ASUS P5K o ASUS P5KC o ASUS P5KPL-C o ASUS P5KPL-VM o ASUS P5K-SE o ASUS P5K-V o ASUS P5L-MX o ASUS P5DL2-VM o ASUS P5L-VM 1394 o ASUS G2S LOADER TUNABLES
Tunables can be set at the loader(8) prompt before booting the kernel or stored in loader.conf(5). hw.age.msi_disable This tunable disables MSI support on the Ethernet hardware. The default value is 0. hw.age.msix_disable This tunable disables MSI-X support on the Ethernet hardware. The default value is 0. SYSCTL VARIABLES
The following variables are available as both sysctl(8) variables and loader(8) tunables: dev.age.%d.int_mod Maximum amount of time to delay interrupt processing in units of 2us. The accepted range is 0 to 65000, the default is 50 (100us). Value 0 completely disables the interrupt moderation. dev.age.%d.process_limit Maximum amount of Rx events to be processed in the event loop before rescheduling a taskqueue. The accepted range is 30 to 255, the default value is 128 events. The interface does not need to be brought down and up again before a change takes effect. dev.age.%d.stats Display lots of useful MAC counters maintained in the driver. SEE ALSO
altq(4), arp(4), miibus(4), netintro(4), ng_ether(4), vlan(4), ifconfig(8) HISTORY
The age driver was written by Pyun YongHyeon <yongari@FreeBSD.org>. It first appeared in FreeBSD 7.1. BSD
September 18, 2008 BSD
All times are GMT -4. The time now is 11:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy