Sponsored Content
Top Forums Shell Programming and Scripting Sed wraps some lines, not all Post 302505370 by alan on Wednesday 16th of March 2011 07:17:05 PM
Old 03-16-2011
Sed wraps some lines, not all

Greetings. I am using SED to cleanup files that are laid out like so:

Code:
   
ReceiverID=028936004663
SerialNumber=WD-WCAV95708405
Currenttemp=44C
PowerOnHours=3663h
ReceiverID=028923894902
SerialNumber=WD-WCAV9A766701
Currenttemp=49C
PowerOnHours=2215h

My boss wants files like this one to be tab ("\t") delimited like so

Code:
ReceiverID=...(tab)SerialNumber=...(tab)Currenttemp=...(tab)PowerOnHours=...(newline)
ReceiverID=...(tab)SerialNumber=...(tab)Currenttemp=...(tab)PowerOnHours=...(newline)...

1) first, I added a newline to mark each record
Code:
sed -i 's/h/h\n/g' infile

,
2) then, I added the the tab delimiter
Code:
    sed -i '/.$/N; s/.\n/\t/' infile

It works but strangely, not everywhere. This is the output I get

Code:
ReceiverID=...(tab)SerialNumber=...(tab???)
Currenttemp=...(tab)PowerOnHours=...(newline)
ReceiverID=...(tab)SerialNumber=...(tab???)
Currenttemp=...(tab)PowerOnHours=...(newline)

What am I missing?? I welcome your input. Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Pinting a file on Solaris 8 that wraps around.

Can someone please explain how I can print a file and get the text to wrap around instead of truncating the line and missing the rest of the text? There are a few reports that were generated and I am trying to print them but after wasting 200 sheets of paper I realized that the lines were... (1 Reply)
Discussion started by: rtoba
1 Replies

2. UNIX for Dummies Questions & Answers

how to use sed to get last 6 lines

dear experts, Sorry im a newbie. i have a file called INA.txt and it contains How do i get the 6 lines before "INA 2007-09-05" to appear? I tried using grep -A6, it doesnt work. Pls help. (5 Replies)
Discussion started by: aismann
5 Replies

3. Shell Programming and Scripting

sed problem - delete all lines until a match on 2 lines

First of all, I know this can be more eassily done with perl or other scripting languages but, that's not the issue. I need this in sed. (or wander if it's possible ) I got a file (trace file to recreate the control file from oracle for the dba boys) which contains some lines another line... (11 Replies)
Discussion started by: plelie2
11 Replies

4. Shell Programming and Scripting

bash script too many fields wraps to multiple lines

Hello. I'm trying to write a script to take a 5 field file, do some math, and extend it to 9 fields. Problem is, the script keeps wrapping it to two lines, even tho 9 fields, tab separated (even comma separated) doesn't fill the screen. Even if it did, I'm eventually copying it to an excel ... (2 Replies)
Discussion started by: JoeNess
2 Replies

5. Shell Programming and Scripting

sed show lines text between 2 blank lines

I have a file like blah blah blah blah this is the text I need, which might be between 1-4 lines, but always has a blank line above and below it, and is at the end of the text file the code tags don't show the trailing blank line. I started by deleting the last blank line with: ... (2 Replies)
Discussion started by: unclecameron
2 Replies

6. Shell Programming and Scripting

Sed/awk to delete single lines that aren't touching other lines

Hello, I'm trying to figure out how to use sed or awk to delete single lines in a file. By single, I mean lines that are not touching any other lines (just one line with white space above and below). Example: one two three four five six seven eight I want it to look like: (6 Replies)
Discussion started by: slimjbe
6 Replies

7. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum using sed, awk

Hi friends, This is sed & awk type question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers whenever i find it and produce an output file with the sum. For example ###start of input text file #### abc def ghi 1 2 3 4 kjld random... (3 Replies)
Discussion started by: kaaliakahn
3 Replies

8. Shell Programming and Scripting

sed print all lines between second and third identical lines

I am trying to extract a table of data (mysql query output) from a log file. I need to print everything below the header and not past the end of the table. I have spent many hours searching with little progress. I am matching the regexp +-\{99\} with no problem. I just can't figure out how to print... (5 Replies)
Discussion started by: godfreydanials
5 Replies

9. Shell Programming and Scripting

Use sed to print first n lines and last n lines of an output.

Use sed to print first n lines and last n lines of an output. For example: n=10 Can it be done? Thanks. (7 Replies)
Discussion started by: carloszhang
7 Replies

10. Shell Programming and Scripting

ksh sed - Extract specific lines with mulitple occurance of interesting lines

Data file example I look for primary and * to isolate the interesting slot number. slot=`sed '/^primary$/,/\*/!d' filename | tail -1 | sed s'/*//' | awk '{print $1" "$2}'` Now I want to get the Touch line for only the associate slot number, in this case, because the asterisk... (2 Replies)
Discussion started by: popeye
2 Replies
SEND_GEARMAN(8) 					  System Administration Utilities					   SEND_GEARMAN(8)

NAME
send_gearman - Submit active and passive check results to a gearman job server DESCRIPTION
usage: send_gearman [ --debug=<lvl> ] [ --help|-h ] [ --config=<configfile> ] [ --server=<server> ] [ --timeout|-t=<timeout> ] [ --delimiter|-d=<delimiter> ] [ --encryption=<yes|no> ] [ --key=<string> ] [ --keyfile=<file> ] [ --host=<hostname> ] [ --service=<servicename> ] [ --result_queue=<queue> ] [ --message|-m=<pluginoutput> ] [ --returncode|-r=<returncode> ] for sending active checks: [ --active ] [ --starttime=<unixtime> ] [ --finishtime=<unixtime> ] [ --latency=<seconds> ] plugin output is read from stdin unless --message is used. Use this mode when plugin has multiple lines of plugin output. Note: When using a delimiter (-d) you may also submit one result for each line. Service Checks: <host_name>[tab]<svc_description>[tab]<return_code>[tab]<plugin_output>[newline] Host Checks: <host_name>[tab]<return_code>[tab]<plugin_output>[newline] see README for a detailed explaination of all options. SEE ALSO
The Mod Gearman documentation is available in /usr/share/doc/mod-gearman/README.html send_gearman 1.3.6-1 July 2012 SEND_GEARMAN(8)
All times are GMT -4. The time now is 10:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy