script for a 3 line paragraph


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script for a 3 line paragraph
# 1  
Old 12-17-2007
script for a 3 line paragraph

i would like to ask how to make a script that in evry 3 lines of my paragraph(below) it would appear like this:

$ cat myparagraph
this is line 1
this is line 2
this is line3
this is line 4
this is 5
this 6
this is 7
this 8
====================================================
$ cat myparagraphnew

this is line 1
this is line 2
this is line3

this is line 4
this is 5
this 6

this is 7
this 8
# 2  
Old 12-17-2007
Code:
awk '!( NR  % 3 ) {$0 = $0"\n"} 1' myparagraph > myparagraphnew

# 3  
Old 12-18-2007
thanks dude ur so great
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script to extract paragraph with globs in it

Hi, Its been a long time since I have used Bash to write a script so am really struggling here. Need the gurus to help me out. uname -a Linux lxserv01 2.6.18-417.el5 i have a text file with blocks of code written in a similar manner ******* BEGIN MESSAGE ******* Station /... (12 Replies)
Discussion started by: dsid
12 Replies

2. Shell Programming and Scripting

How to extract multiple line in a paragraph? Please help.

Hi all, The following lines are taken from a long paragraph: Labels of output orbitals: RY* RY* RY* RY* RY* RY* 1\1\GINC-COMPUTE-1-3\SP\UB3LYP\6-31G\C2H5Cr1O1(1+,5)\LIUZHEN\19-Jan-20 10\0\\# ub3lyp/6-31G pop=(nbo,savenbo) gfprint\\E101GECP\\1,5\O,0,-1.7 ... (1 Reply)
Discussion started by: liuzhencc
1 Replies

3. UNIX for Dummies Questions & Answers

Output text from 1st paragraph in file w/ a specific string through last paragraph of file w/ string

Hi, I'm trying to output all text from the first paragraph in a file that contains a specific string through the last paragraph in that file that contains that string. Previously, I was outputting just each paragraph with that search string with: cat in_file | nawk '{RS=""; FS="\n";... (2 Replies)
Discussion started by: carpenn
2 Replies

4. Shell Programming and Scripting

Pattern in a paragraph

Hi, I have read similar questions and I was not able to get a solution, so please help :) I have two files: 1-Pattern file contains list of patterns pattern1 pattern2 pattern3 pattern4 .... pattern# 2-input file in the format >hdhfshsdfjhpattern1xmbxmbxnmv... (4 Replies)
Discussion started by: tbakheet
4 Replies

5. Shell Programming and Scripting

print first line of each paragraph

Hi everybody, Say I have a file that looks like this: How could I print a new file with only the first lines of each paragraph: (3 Replies)
Discussion started by: thedude
3 Replies

6. Shell Programming and Scripting

Need your HELP:: Shell script to detect paragraph in coordinate-based code.

Hi Friends!! I have obtained following output from a tool called pdftoxml: <xml> <text top="423" left="521" width="333" height="20" font="3">Although the the number of fuzzy rules of a system is </text> <text top="441" left="500" width="355" height="20" font="3">directly dependant on these... (2 Replies)
Discussion started by: parshant_bvcoe
2 Replies

7. Shell Programming and Scripting

script to list out the output in one paragraph

Hi All, I want to run 5 `ps -ef | grep ` cmds in one script and i want the script to give me return code 0 if everything is OK. If it notices one of the processes is not there, it will prompt me the process name and advice me to check it. I've wrote a script that separates the output but I want... (2 Replies)
Discussion started by: fara_aris
2 Replies

8. Shell Programming and Scripting

help, using awk to get paragraph

Hi, I'm trying to find pattern in log file. I'm using awk to search the pattern and print the paragraph. And it's not working well like I want. The file actually is TCAP message, it has format like this : ... ... ... ***************************************** INCOMING TCAP MESSAGE At... (6 Replies)
Discussion started by: kunimi
6 Replies

9. UNIX for Dummies Questions & Answers

SED or AWK: Appending a line Identifier that changes with paragraph?

Have another question that has been eluding me all day. I have data file I'm trying to reformat so that each line is appended with an ID code, but the ID code needs to update as it searches through the file. I.e. ----Begin Original Datafile----- Condition = XXX Header Line 1 Header... (1 Reply)
Discussion started by: selkirk
1 Replies

10. Shell Programming and Scripting

Convert a paragraph to single line

I need to check the count of pipes on each line of the data to make sure we 4 pipes if its less i need to keep adding the string to form a single line ( Need to join/ concat the below lines until i get the 4 pipes which is end of record ). This fields is basicall a memo where the user would have... (6 Replies)
Discussion started by: rimss
6 Replies
Login or Register to Ask a Question