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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to extract multiple line in a paragraph? Please help.
# 1  
Old 04-28-2010
How to extract multiple line in a paragraph? Please help.

Hi all,

The following lines are taken from a long paragraph:
Code:
 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
 94164,0.666176,0.000085\Cr,0,-0.468984,-0.491233,-0.000037\C,0,1.70397
 4,0.296251,-0.679725\C,0,1.70395,0.296149,0.679775\H,0,2.109579,-0.541
 882,-1.246519\H,0,2.109538,-0.542069,1.246456\H,0,1.418343,1.180349,1.
 248068\H,0,1.418389,1.180538,-1.247894\H,0,-1.894474,1.62884,-0.000203
 \\Version=EM64T-G03RevE.01\State=5-A\HF=-1198.5414318\S2=6.037917\S2-1
 =0.\S2A=6.000171\RMSD=5.527e-05\Thermal=0.\Dipole=0.9284418,-0.5041636
 ,-0.0005116\PG=C01 [X(C2H5Cr1O1)]\\@

How can I extract some lines starting from "1\1\GINC-COMPUTE-1-3..." to the END???

like this:
Code:
 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
 94164,0.666176,0.000085\Cr,0,-0.468984,-0.491233,-0.000037\C,0,1.70397
 4,0.296251,-0.679725\C,0,1.70395,0.296149,0.679775\H,0,2.109579,-0.541
 882,-1.246519\H,0,2.109538,-0.542069,1.246456\H,0,1.418343,1.180349,1.
 248068\H,0,1.418389,1.180538,-1.247894\H,0,-1.894474,1.62884,-0.000203
 \\Version=EM64T-G03RevE.01\State=5-A\HF=-1198.5414318\S2=6.037917\S2-1
 =0.\S2A=6.000171\RMSD=5.527e-05\Thermal=0.\Dipole=0.9284418,-0.5041636
 ,-0.0005116\PG=C01 [X(C2H5Cr1O1)]\\@

I searched in this forum and found a script "
Code:
awk -v RS= '/^\ 1\\1\\/' myfile".

If there is a blank line before the line "1\1\GINC-COMPUTE-1-3"", it should work.
Unfortunately, there is no blank line before the line "1\1\GINC-COMPUTE-1-3"". How can I modify this script?

Eventually, I want to get a coordinate file like this:
Code:
E101GECP

O    0    -1.794164    0.666176    0.000085
Cr   0    -0.468984    -0.491233    -0.000037
C    0    1.703974    0.296251    -0.679725
C    0    1.70395    0.296149    0.679775
H    0    2.109579    -0.541882    -1.246519
H    0    2.109538    -0.542069    1.246456
H    0    1.418343    1.180349    1.248068
H    0    1.418389    1.180538    -1.247894
H    0    -1.894474    1.62884    -0.000203


HF=-1198.5414318

\\@

Is that possible? I think it would be a tough task to do with "awk".
Please help. Thanks a lot!

ZHEN

Last edited by liuzhencc; 04-29-2010 at 11:16 PM..
# 2  
Old 04-28-2010
If there's not a blank line, what is there to tell us where the paragraph ends?
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 a paragraph containing a given string?

Hello: Have a very annoying problem: Need to extract paragraphs with a specific string in them from a very large file with a repeating record separator. Example data: a file called test.out CREATE VIEW view1 AS something FROM table1 ,table2 as A, table3 (something FROM table4) FROM... (15 Replies)
Discussion started by: delphys
15 Replies

3. UNIX for Dummies Questions & Answers

Extract paragraph that contains a value x<-30

I am using OSX. I have a multi-mol2 file (text file with coordinates and info for several molecules). An example of two molecules in the file is given below for molecule1 and molecule 2. The total file contains >50,000 molecules. I would like to extract out and write to another file only the... (2 Replies)
Discussion started by: Egy
2 Replies

4. Shell Programming and Scripting

Extract multiple strings from line

Hello I have an output that has a string between quotes and another between square brackets on the same line. I need to extract these 2 strings Example line Device "nrst3a" attributes=(0x4) RAW SERIAL_NUMBER=SNL2 Output should look like nrst3a VD073AV1443BVW00083 I was trying with sed... (3 Replies)
Discussion started by: bombcan
3 Replies

5. Shell Programming and Scripting

Extract string from multiple file based on line count number

Hi, I search all forum, but I can not find solutions of my problem :( I have multiple files (5000 files), inside there is this data : FILE 1: 1195.921 -898.995 0.750312E-02-0.497526E-02 0.195382E-05 0.609417E-05 -2021.287 1305.479-0.819754E-02 0.107572E-01 0.313018E-05 0.885066E-05 ... (15 Replies)
Discussion started by: guns
15 Replies

6. Shell Programming and Scripting

How to search for multiple lines and put them into one paragraph?

Dear all, I'm trying to manipulate a data file and putting a certain lines into one paragraph. What am I actually want to do is that search some lines in a data file. These lines begin with "1\1\GINC-" and end with "\\@" or the following two empty lines as shown in blue. A part of the text... (11 Replies)
Discussion started by: liuzhencc
11 Replies

7. UNIX for Dummies Questions & Answers

awk, extract last line of multiple files

Hi, I have a directory full of *.txt files. I would like to print the last line of every file to screen. I know you can use FNR for printing the first line of each file, but how do I access the last line of each file? This code doesn't work, it only prints the last line of the last file:BEGIN... (5 Replies)
Discussion started by: Liverpaul09
5 Replies

8. Shell Programming and Scripting

how to extract multiple strings from a line

Hi I have the following requirement. i have the following line from a log file one : two : Three : four : five : six : seven : eight :nine :ten Now can you pls help what i should do to get only the following output from the above line two : five : six : seven : Eight appreciate your... (3 Replies)
Discussion started by: vin_eme
3 Replies

9. Linux

Extract a paragraph

Hi , Unix.com has been life saver for me I admit :) I am trying to extract a paragraph based on matching pattern "CREATE TABLE " from a ddl file . The paragraphs are seperated by blank line . Input file is #cat zip.20080604.sql1 CONNECT TO TST103 SET SESSION_USER OPSDM002 ... (2 Replies)
Discussion started by: capri_drm
2 Replies

10. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: invinzin21
2 Replies
Login or Register to Ask a Question