Sponsored Content
Top Forums Shell Programming and Scripting How to extract multiple line in a paragraph? Please help. Post 302417075 by liuzhencc on Wednesday 28th of April 2010 12:22:36 PM
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..
 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
RRDUPDATE(1)							      rrdtool							      RRDUPDATE(1)

NAME
rrdupdate - Store a new set of values into the RRD SYNOPSIS
rrdtool {update | updatev} filename [--template|-t ds-name[:ds-name]...] [--daemon address] [--] N|timestamp:value[:value...] at- timestamp@value[:value...] [timestamp:value[:value...] ...] DESCRIPTION
The update function feeds new data values into an RRD. The data is time aligned (interpolated) according to the properties of the RRD to which the data is written. updatev This alternate version of update takes the same arguments and performs the same function. The v stands for verbose, which describes the output returned. updatev returns a list of any and all consolidated data points (CDPs) written to disk as a result of the invocation of update. The values are indexed by timestamp (time_t), RRA (consolidation function and PDPs per CDP), and data source (name). Note that depending on the arguments of the current and previous call to update, the list may have no entries or a large number of entries. Since updatev requires direct disk access, the --daemon option cannot be used with this command. filename The name of the RRD you want to update. --template|-t ds-name[:ds-name]... By default, the update function expects its data input in the order the data sources are defined in the RRD, excluding any COMPUTE data sources (i.e. if the third data source DST is COMPUTE, the third input value will be mapped to the fourth data source in the RRD and so on). This is not very error resistant, as you might be sending the wrong data into an RRD. The template switch allows you to specify which data sources you are going to update and in which order. If the data sources specified in the template are not available in the RRD file, the update process will abort with an error message. While it appears possible with the template switch to update data sources asynchronously, RRDtool implicitly assigns non-COMPUTE data sources missing from the template the *UNKNOWN* value. Do not specify a value for a COMPUTE DST in the update function. If this is done accidentally (and this can only be done using the template switch), RRDtool will ignore the value specified for the COMPUTE DST. --daemon address If given, RRDTool will try to connect to the caching daemon rrdcached at address and will fail if the connection cannot be established. If the connection is successfully established the values will be sent to the daemon instead of accessing the files directly. For a list of accepted formats, see the -l option in the rrdcached manual. N|timestamp:value[:value...] The data used for updating the RRD was acquired at a certain time. This time can either be defined in seconds since 1970-01-01 or by using the letter 'N', in which case the update time is set to be the current time. Negative time values are subtracted from the current time. An AT_STYLE TIME SPECIFICATION (see the rrdfetch documentation) may also be used by delimiting the end of the time specification with the '@' character instead of a ':'. Getting the timing right to the second is especially important when you are working with data-sources of type COUNTER, DERIVE or ABSOLUTE. When using negative time values, options and data have to be separated by two dashes (--), else the time value would be parsed as an option. See below for an example. When using negative time values, options and data have to be separated by two dashes (--), else the time value would be parsed as an option. See below for an example. The remaining elements of the argument are DS updates. The order of this list is the same as the order the data sources were defined in the RRA. If there is no data for a certain data-source, the letter U (e.g., N:0.1:U:1) can be specified. The format of the value acquired from the data source is dependent on the data source type chosen. Normally it will be numeric, but the data acquisition modules may impose their very own parsing of this parameter as long as the colon (:) remains the data source value separator. ENVIRONMENT VARIABLES
The following environment variables may be used to change the behavior of "rrdtool update": RRDCACHED_ADDRESS If this environment variable is set it will have the same effect as specifying the "--daemon" option on the command line. If both are present, the command line argument takes precedence. EXAMPLES
o "rrdtool update demo1.rrd N:3.44:3.15:U:23" Update the database file demo1.rrd with 3 known and one *UNKNOWN* value. Use the current time as the update time. o "rrdtool update demo2.rrd 887457267:U 887457521:22 887457903:2.7" Update the database file demo2.rrd which expects data from a single data-source, three times. First with an *UNKNOWN* value then with two regular readings. The update interval seems to be around 300 seconds. o "rrdtool update demo3.rrd -- -5:21 N:42" Update the database file demo3.rrd two times, using five seconds in the past and the current time as the update times. o "rrdtool update --cache /var/lib/rrd/demo3.rrd N:42" Update the file "/var/lib/rrd/demo3.rrd" with a single data source, using the current time. If the caching daemon cannot be reached, do not fall back to direct file access. o "rrdtool update --daemon unix:/tmp/rrdd.sock demo4.rrd N:23" Use the UNIX domain socket "/tmp/rrdd.sock" to contact the caching daemon. If the caching daemon is not available, update the file "demo4.rrd" directly. WARNING: Since a relative path is specified, the following disturbing effect may occur: If the daemon is available, the file relative to the working directory of the daemon is used. If the daemon is not available, the file relative to the current working directory of the invoking process is used. This may update two different files depending on whether the daemon could be reached or not. Don't do relative paths, kids! AUTHORS
Tobias Oetiker <tobi@oetiker.ch>, Florian Forster <octo at verplant.org> 1.4.7 2009-06-02 RRDUPDATE(1)
All times are GMT -4. The time now is 08:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy