Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Output text from 1st paragraph in file w/ a specific string through last paragraph of file w/ string Post 302411881 by Corona688 on Friday 9th of April 2010 04:22:28 PM
Old 04-09-2010
First off you get a useless use of cat award.

What you want is a bit trickier than just grepping for something, since it means needing to store lines until you've processed the whole file... Does your system have bash or perl? I'd write a script.

Code:
#!/bin/bash

STRING="MARK"
MODE="start"

TMP=`mktemp`
exec 5>$TMP

while IFS="" read LINE
do
        case "$MODE" in
        start)
                if [[ "$LINE" =~ $STRING ]]
                then
                        MODE="mid"
                        echo "$LINE"
                fi
                ;;
        mid)    if [[ "$LINE" =~ $STRING ]]
                then
                        cat $TMP
                        echo $LINE
                        echo > $TMP
                        exec 5>$TMP
                else
                        echo "$LINE" >&5
                fi
                ;;
        esac
        :
done <<EOF
a b
MARK
asdf1
asdf2
MARK
asdf3
asdf4
MARK
qwerty5
EOF

rm -f $TMP

To pipe stdin through it instead of the here-document, simply delete everything from <<EOF to EOF.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

selecting each paragraph and put it into a file...help me

Dear Friends, I need a shell script. I am facing a problem while selecting the text that is between start and end tags. and insert the paragraph into a file1, next paragraph in file2...... experts please help. i have a file which contains, -------------- <abc> 111some text some text some... (2 Replies)
Discussion started by: swamymns
2 Replies

2. Shell Programming and Scripting

Replacing a paragraph between pattern , with the content 4m another file

hi, i wanted to put the output of file f1 into the pattern space of file f2 f1: wjwjwjwjwjwjwj //these line go in file f2 jwjwjwjwjwjjwjw wjwjwjwjjwjwjwj f2: Pattern_start __________ //these are the line to be replaced __________ Pattern_end i m... (4 Replies)
Discussion started by: go4desperado
4 Replies

3. Shell Programming and Scripting

Search for a particular string in a paragraph in a text

Hi all, i'm new to this community. I am trying to write a script which will fetch ftp completion time of a file from a paragraph of a big text file ( which contains multiple paragraphs) . Each paragraph will have ftp details.. Now I dont know how to fetch process time within a paragraph of... (3 Replies)
Discussion started by: prachiagra
3 Replies

4. Shell Programming and Scripting

Easy way to pull a paragraph from a text file?

I have a collection of text files that comprise a mailing list archive. I grep them to find an email that interests me, then open the file in a text editor to find the surrounding paragraph of text. Is there an easy way to do this from the shell instead? (2 Replies)
Discussion started by: CRGreathouse
2 Replies

5. Shell Programming and Scripting

Print each paragraph in a text file into excel file

Hi, I have a below text file, which needs to be printed into attached excel file. Please help me. Thanks (4 Replies)
Discussion started by: prash358
4 Replies

6. Windows & DOS: Issues & Discussions

Removing anything from text file except specific string

So, I have a text file that looks like this: 0,0: (168,168,176) #A8A8B0 srgb(168,168,176) 1,0: (168,168,176) #A8A8B0 srgb(168,168,176) 2,0: (166,166,174) #A6A6AE srgb(166,166,174) 3,0: (166,166,174) #A6A6AE srgb(166,166,174) 4,0: (168,168,176) #A8A8B0 srgb(168,168,176) 5,0:... (0 Replies)
Discussion started by: pasc
0 Replies

7. Shell Programming and Scripting

How to read all data after a specific string from a text file ?

Hi, I have a file(input.txt) and trying to format as output.txt. See the attached file format. Note: This is a windows file (DOS format) and the commands are also going to execute on windows. Basically I am trying to capture all the data in between Local Group Memberships and Global Group... (10 Replies)
Discussion started by: Monoj2014
10 Replies

8. Shell Programming and Scripting

Read paragraph from file

Hi, I have a file containing SQL commands in following format. I need to run the SQLs separately and also print the status of SQL, successful/unsuccessful. File : SQL.dat ## SQL1 select * from dual; ## SQL2 select user from dual10; Expected output: SQL1:PASS SQL2:FAIL Started... (3 Replies)
Discussion started by: bhupinder08
3 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

Join Lines every paragraph in a file.txt

Hi all, Is there any idea on how to automate convert the paragraph in one line in a file, this will happen after OCR the documents, OCR split every paragraph. I need to join all the paragraph in one line. #cat file.txtThe Commission on Higher Education (CHED) was created through Republic Act... (7 Replies)
Discussion started by: lxdorney
7 Replies
fribidi_log2vis(3)						Programmer's Manual						fribidi_log2vis(3)

NAME
fribidi_log2vis - get visual string SYNOPSIS
#include <fribidi.h> FriBidiLevel fribidi_log2vis ( const FriBidiChar *str, const FriBidiStrIndex len, FriBidiParType *pbase_dir, FriBidiChar *visual_str, FriBidiStrIndex *positions_L_to_V, FriBidiStrIndex *positions_V_to_L, FriBidiLevel *embedding_levels ); PARAMETERS
const FriBidiChar *str Input logical string. const FriBidiStrIndex len Input string length. FriBidiParType *pbase_dir Requested and resolved paragraph base direction. Possible values for a FriBidiParType are as follows: FRIBIDI_PAR_LTR Left-To-Right paragraph. FRIBIDI_PAR_RTL Right-To-Left paragraph. FRIBIDI_PAR_ON DirectiOn-Neutral paragraph. FRIBIDI_PAR_WLTR Weak Left To Right paragraph. FRIBIDI_PAR_WRTL Weak Right To Left paragraph. FriBidiChar *visual_str Output visual string. FriBidiStrIndex *positions_L_to_V Output mapping from logical to visual string positions. FriBidiStrIndex *positions_V_to_L Output mapping from visual string back to the logical string positions. FriBidiLevel *embedding_levels Output list of embedding levels. DESCRIPTION
This function converts the logical input string to the visual output strings as specified by the Unicode Bidirectional Algorithm. As a side effect it also generates mapping lists between the two strings, and the list of embedding levels as defined by the algorithm. If NULL is passed as any of the the lists, the list is ignored and not filled. This function is obsolete because it only handles one-line paragraphs. Please consider using other functions instead. Deprecated. RETURNS
Maximum level found plus one, or zero if any error occured (memory allocation failure most probably). SEE ALSO
fribidi_charset_to_unicode(3), fribidi_unicode_to_charset(3), fribidi_parse_charset(3), fribidi_shape_arabic(3), fribidi_get_par_direc- tion(3), fribidi_get_par_embedding_levels(3), fribidi_reorder_line(3), fribidi_get_bidi_type(3), fribidi_get_bidi_types(3), fribidi_get_bidi_type_name(3), fribidi_debug_status(3), fribidi_mirroring_status(3), fribidi_set_mirroring(3), fribidi_reorder_nsm_sta- tus(3), fribidi_set_reorder_nsm(3), fribidi_log2vis_get_embedding_levels(3), fribidi_get_type(3), fribidi_get_type_internal(3), fribidi_remove_bidi_marks(3), fribidi_join_arabic(3), fribidi_get_joining_type(3), fribidi_get_joining_types(3), fribidi_get_join- ing_type_name(3), fribidi_get_mirror_char(3), fribidi_shape_mirroring(3), fribidi_shape(3) GNU FriBidi 0.19.3 25 August 2012 fribidi_log2vis(3)
All times are GMT -4. The time now is 04:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy