Taking 3 greped/awked lines of text


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Taking 3 greped/awked lines of text
# 1  
Old 10-15-2010
Taking 3 greped/awked lines of text

Say I used grep and awk for taking text out of a text file...
I now /have 3 lines of text that I want to combine to make 1 line.

What command could I use to do this?
...
display line 1 twice then
sed s/$line1/$line2/ ????... display line 2 twice then
sed s/$line2/$line3/
# 2  
Old 10-15-2010
Code:
sed '
  $!N
  $!N
  s/\n/ /g
 '

This User Gave Thanks to DGPickett For This Post:
# 3  
Old 10-15-2010
makes sense to me thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies

2. Shell Programming and Scripting

awk to skip lines find text and add text based on number

I am trying to use awk skip each line with a ## or # and check each line after for STB= and if that value in greater than or = to 0.8, then at the end of line the text "STRAND BIAS" is written in else "GOOD". So in the file of 4 entries attached. awk tried: awk NR > "##"' "#" -F"STB="... (6 Replies)
Discussion started by: cmccabe
6 Replies

3. Shell Programming and Scripting

Read n lines from a text files getting n from within the text file

I dont even have a sample script cause I dont know where to start from. My data lookes like this > sat#16 #data: 15 site:UNZA baseline: 205.9151 0.008 -165.2465 35.8109 40.6685 21.9148 121.1446 26.4629 -18.4976 33.8722 0.017 -165.2243 48.2201 40.6908 ... (8 Replies)
Discussion started by: malandisa
8 Replies

4. Shell Programming and Scripting

Taking the averages of columns with deletion of some lines

Hi, I am in stage of post processing some of my results. I wanted to plot the data against the three axis x,y,z. The data file is quite complicated and i have to take the average of x, y,z over different steps of my test. A typical file look like below: Time taken:4s No.of series : 3... (6 Replies)
Discussion started by: begin_shell
6 Replies

5. Shell Programming and Scripting

PERL or SHELL Scrript to search in Directories by taking line by line from a text file

Unix box server version *********** >uname -r B.11.00 >echo $SHELL /usr/bin/ksh --> in this server, I have the path like /IMbuild/dev/im0serv1 ---> in that directory I have the folders startup(.jsp files nearly 100 jsp's ) and scripts(contains .js files nearly 100 files) ... (9 Replies)
Discussion started by: pasam
9 Replies

6. 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

7. Shell Programming and Scripting

Print lines between two lines after grep for a text string

I have several very large file that are extracts from Oracle tables. These files are formatted in XML type syntax with multiple entries like: <ROW> some information more information </ROW> I want to grep for some words, then print all lines between <ROW> AND </ROW>. Can this be done with AWK?... (7 Replies)
Discussion started by: jbruce
7 Replies

8. Shell Programming and Scripting

Format Time with Awked Output

Hi, I would like the 2nd column in this log file to display as %k%S(00:00) in a new file. See my script and desired output below. 05-25-2010 21:45:49 1616 1615 0 0 0 0 0 0 0 05-23-2010 21:55:49 1495 1493 0 0 0 3 0 0 0 05-23-2010 22:05:49 1750 1750 0 0 0 0 0 0 0 05-24-2010 22:15:49... (12 Replies)
Discussion started by: ravzter
12 Replies

9. Shell Programming and Scripting

[bash help]Adding multiple lines of text into a specific spot into a text file

I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it. For example, Here is a portion of a zone file. IN NS ns1.domain.tld. IN NS ns2.domain.tld. IN ... (2 Replies)
Discussion started by: cdn_humbucker
2 Replies

10. Shell Programming and Scripting

Perl: taking text from a .txt file

How would i go about the following, I open a text document with loads of text, about 150 lines e.g. "Best Time: 02:55.88" How would i get perl just to take the time and put into a variable but also be able to take any time like that from the file?? i've done this so far to open the... (2 Replies)
Discussion started by: perleo
2 Replies
Login or Register to Ask a Question