Sponsored Content
Top Forums Shell Programming and Scripting Sed wraps some lines, not all Post 302505380 by LivinFree on Wednesday 16th of March 2011 08:22:19 PM
Old 03-16-2011
Here's my crack at it, although if you're working with huge files, it might not be a great idea to load that much into the Hold buffer:
Code:
sed -n '1h;2,$H;${g;s/\n/\t/g;s/\tReceiver/\nReceiver/g;p}' infile

Or in shell:
Code:
#! /bin/bash
while read line; do
    [[ "$line" =~ PowerOnHours ]] && { 
        printf '%s\n' "$line"
    } || {
        printf '%s\t' "$line"
    }
done <infile

This User Gave Thanks to LivinFree For This Post:
 

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
line(1)                                                            User Commands                                                           line(1)

NAME
line - read one line SYNOPSIS
line DESCRIPTION
The line utility copies one line (up to and including a new-line) from the standard input and writes it on the standard output. It returns an exit status of 1 on EOF and always prints at least a new-line. It is often used within shell files to read from the user's terminal. EXIT STATUS
Exit status is: 0 Successful completion >0 End-of-file on input. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
sh(1), read(2), attributes(5) SunOS 5.10 1 Feb 1995 line(1)
All times are GMT -4. The time now is 02:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy