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 shows as follows, (the sign "==>| |<==" is used to show that each line begins with a space, which is not contained in the original file. The original file also shown at the end of this post for your script testing.)
The expect output file is,
the original file is put as follows for testing.
Sorry for my poor English. I hope I have made myself clear. In short, get the blue part and put into one paragraph.
Thank you in advanced for your kind help.
ZHEN
Last edited by liuzhencc; 11-27-2010 at 06:18 AM..
I also search google and find another way to do this work,
The idea is to use the 'sed' work to get some continuous data begin with "1\1\GINC-" and end with "\\@". These two points are unique in my data sheet. So, It works!
The second line 'tr' is used to delete the "\n" at each line and put these multiple lines into single line. The parallel command 'sed "s. ..g"' is used to remove the empty space in the text, which is introduced in the original data file. Although it may remove all the single white space in the data file and put some some words into a continuous string. I don't mind this, becasuse my interest is to get some numbers stored in the data, which may be beaked by the "\n" at the end of each line and the "withe space" the the beginning of each line. So, Work is done.
Thanks. If I was not able to make myself clear, pardon me for my English. Learning a good English is my dream.
how to find multiple lines in to multiple files if matched lines then do
f1 f2 f3 are files ,lines contain matched lines
f1
asdasdasdasd
asdasdasdasd
abc
def
Business date cannot be as of date
ghi
sdasdasdasda
asdasdasdada
f2 (1 Reply)
This is for AIX 6.1, I've a flat file and the format is like this
DECLARE
some statements;
BEGIN
some statements;
END;
I've to search BEGIN and replace it with the following 4 lines
BEGIN
For x in 1..1
LOOP
BEGIN
Similarly I've to search END and replace it with the... (7 Replies)
hey guys,
I tried searching but most 'search and replace' questions are related to one liners.
Say I have a file to be replaced that has the following:
$ cat testing.txt
TESTING
AAA
BBB
CCC
DDD
EEE
FFF
GGG
HHH
ENDTESTING
This is the input file: (3 Replies)
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)
Hi,
I have a requirement to search for a string in a large log file along with few lines before and after the the string. The following script was sufficient to search such an entry.
STRING_TO_GREP="$1"
FILE_TO_GREP="$2"
NUMBER_OF_LINES_BEFORE=$3
NUMBER_OF_LINES_AFTER=$4
for i in `grep... (3 Replies)
Hi,
I have to search those statements from the file which starts from "shanky"(only shanky, shanky09 or 09shanky is not allowed) and ends with ");". These two string can be in a same line or different line. And also i have to negate those lines which starts with #.
Can any one please give me... (2 Replies)
I have a file that contains the following lines
the brown quick fox
jumped over
the white laze dog
0123456789
I wanted to put the contents of this file into a variable so I used this code:
VAR_LIST=`cat $2`
where $2 is the file name passed as an argument to the script
If I... (3 Replies)
Hi all,
For a intro UNIX course I'm taking, I need to use the command "tr" to display a file on standard output without any newlines (all on one line).
I assume I would start with "cat filename | tr" but don't know what to put after tr.
Any ideas would be lovely!
Thanks. (3 Replies)
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)