Sponsored Content
Top Forums Shell Programming and Scripting sed or awk to convert text files with recurring headings to rows and colum Post 302192597 by suresh3566 on Wednesday 7th of May 2008 10:47:30 AM
Old 05-07-2008
With this script I got the output.

Scipt:
------

awk '
/siteid/ { printf $3 " " };
/spc/ {printf $3 " "} ;
/rset/ {printf $3 "\n" };
' log


Output:
-------
HYD 100 del
DEL 200 hyd
 

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
PRINTF(9)						   BSD Kernel Developer's Manual						 PRINTF(9)

NAME
printf, uprintf, tprintf, log -- formatted output conversion SYNOPSIS
#include <sys/types.h> #include <sys/systm.h> int printf(const char *fmt, ...); void tprintf(struct proc *p, int pri, const char *fmt, ...); int uprintf(const char *fmt, ...); #include <sys/syslog.h> void log(int pri, const char *fmt, ...); DESCRIPTION
The printf(9) family of functions are similar to the printf(3) family of functions. The different functions each use a different output stream. The uprintf() function outputs to the current process' controlling tty, while printf() writes to the console as well as to the log- ging facility. The tprintf() function outputs to the tty associated with the process p and the logging facility if pri is not -1. The log() function sends the message to the kernel logging facility, using the log level as indicated by pri. Each of these related functions use the fmt parameter in the same manner as printf(3). However, printf(9) adds two other conversion speci- fiers. The %b identifier expects two arguments: an int and a char *. These are used as a register value and a print mask for decoding bitmasks. The print mask is made up of two parts: the base and the arguments. The base value is the output base expressed as an integer value; for example, 10 gives octal and 20 gives hexadecimal. The arguments are made up of a sequence of bit identifiers. Each bit identifier begins with an integer value which is the number of the bit (starting from 1) this identifier describes. The rest of the identifier is a string of characters containing the name of the bit. The string is terminated by either the bit number at the start of the next bit identifier or NUL for the last bit identifier. The %D identifier is meant to assist in hexdumps. It requires two arguments: a u_char * pointer and a char * string. The memory pointed to be the pointer is output in hexadecimal one byte at a time. The string is used as a delimiter between individual bytes. If present, a width directive will specify the number of bytes to display. By default, 16 bytes of data are output. The log() function uses syslog(3) level values LOG_DEBUG through LOG_EMERG for its pri parameter (mistakenly called 'priority' here). Alter- natively, if a pri of -1 is given, the message will be appended to the last log message started by a previous call to log(). As these mes- sages are generated by the kernel itself, the facility will always be LOG_KERN. RETURN VALUES
The printf() and the uprintf() functions return the number of characters displayed. EXAMPLES
This example demonstrates the use of the %b and %D conversion specifiers. The function void printf_test(void) { printf("reg=%b ", 3, "102BITTWO1BITONE "); printf("out: %4D ", "AAAA", ":"); } will produce the following output: reg=3<BITTWO,BITONE> out: 41:41:41:41 The call log(LOG_DEBUG, "%s%d: been there. ", sc->sc_name, sc->sc_unit); will add the appropriate debug message at priority ``kern.debug'' to the system log. SEE ALSO
printf(3), syslog(3) BSD
September 8, 2006 BSD
All times are GMT -4. The time now is 03:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy