Hi,
i know that i can format a whole file using
Now, i would like to implement a rule in the following way:
- If a paragraph starts with % (and ends with %), the paragraph should remain unchanged.
- Otherwise the command stated above should be applied to the paragraph.
As I am not familiar enough with shell scripting yet, I did not succeed in implementing a paragraph selection rule.
No one has answered. There is a reason. First off, fmt does not have a rule set, only a defined set of behaviors. We would have to write code to do that.
Next, without example input and expected output we cannot possibly do that, without simply guessing. If you want a quick answer, most modern editors will let you set up a macro to reformat lines in a paragraph. If the file is gigantic, code is a best choice.
Hi,
thanks a lot for your reply! I see the problem...
Unfortunately, I am not able so far to present an approach to the problem which you could correct.
Let me state the problem once more giving an example and afterwards present my ideas of how to solve it:
The file is of the form
I would like to format the paragraphs of type 1 using
such that the output should look as follows:
I am trying to split up the text into pieces containing the different paragraphs and apply the fmt command only on paragraphs of type 1, but unfortunately I am not able to do so far (as I am a beginner) and would appreciate your help.
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
If your file contains many paragraphs, say several thousand, then you may wish to avoid creating additional processes.
The perl code listed below demonstrates reading records as paragraphs, and wrapping non-%-tagged records internally with standard (but possibly not installed) perl module Text/Wrap. There is a bit of overhad in splitting the paragraphs from the scalar to the array. That could be optimized if necessary, but the paragraph-reading tends to simplify the code. Everything is, as usual, a trade-off.
The core of the solution is listed after the versions of OS, commands, and modules are noted.
producing:
The data file was modified to illustrate actual re-formatting, as well as avoidance of it.
Hi,
I have a text with a number of paragraphs in them. My problem is I need to locate certain errors/warning and extract/count them. Problem is I do not know how many paras are there with that particular type of error/warning. I had thought that somehow if I could count the number of... (25 Replies)
I am very new to shell scripting, current try to do a sorting of a text file in paragraphs with ksh script.
example:
File content:
A1100001 line 1 = "testing"
line 2 = something,
line 3 = 100
D1200003 line 1 = "testing"
line 2 = something,
line 3 = 100
B1200003 line 1 =... (3 Replies)
Hi all!
I want to make a code to split sentences into paragraphs maybe
4-5 sentences into one <p>text</p>
there are no new lines in the text string
any ideas with AWK, SSH?
Thank you! (5 Replies)
Hi all,
I want to extract some paragraphs out of a file under certain conditions.
- The paragraph must start with 'fmri'
- The paragraph must contain the string 'restarter svc:/system/svc/restarter:default'
My input is like that :
fmri svc:/system/vxpbx:default
state_time Wed... (4 Replies)
hi,
i have file,
file is separated into parahgraphs by these line(----------).
i want to find out logId = string : "AIALARM", in each parahgraph or page
if found then i want to cut next five lines....
... (3 Replies)
Hello,
I have file which needs to be splitted into multiple line with each line holding 80 bytes.
Im using the fmt command as
fmt -w 80 {filename} > {out filename}
but getting the error
fmt: Too many characters in a word.
Thanks
Use code tags, ty. (7 Replies)
hi,
i am a SED newbie and i need some help. i have a log file as shown below. and i want to search specific Error Code, and fetch the whole paragraph.
...
...
.................
....ErrCode...
.................
...
...
...
.................
....ErrCode...
... (4 Replies)
Hi,
I have a log file which might have certain paragraphs.
Switch not possible Error code 1234
Process number 678
Log not available Error code 567
Process number 874
.....
......
......
Now I create an exception file like this.
cat text.exp
Error code 1234
Process number 874 (7 Replies)
Hi,
I am trying to filter out those paragraphs that contains 'CONNECT', 'alter system switch logfile'. That means say the input file is :
-------------------------------------------------------
Wed Jun 7 00:32:31 2006
ACTION : 'CONNECT'
CLIENT USER: prdadm
CLIENT TERMINAL:
Wed Jun 7... (7 Replies)
Hi everyone,
I have a file with multiple entries and I would like to remove the ones that contain either /A"> or /A/, where A can be any letter of the alphabet. Here's an example of the entries:
<Topic r:id="Top/World/Fran">
<catid>476</catid>
<link... (1 Reply)