Changing paragraph to a width of 80 character


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Changing paragraph to a width of 80 character
# 1  
Old 08-29-2013
Changing paragraph to a width of 80 character

I have the following text file and want to change the paragraphs so that
they fill 80 characters rather than the usual 65 in this case. Is there an easy way to do this?

Code:
All three groups were distinguished by the remarkable
manner in which they moved about on the solar surface, not
only in longitude but also in latitude.
The first group moved forward 5°"2 in longitude, and o 0 ·6
upward in latitude, in· the four days following its formation.
In the fortnight that it was on the further side of the Sun
it moved forward 4°"0 in longitude, and 1°"1 downward in
latitude. It was no'Y a single circular spot, and remained nearly
stationary till its disappearance.
The second group, that of June 16, the principal group of
the year, showed the most extraordin,ary drift, as the first
diagram will show.
Some of the minor irregularities are probably due to faculous
or photospheric mat,ter drifting above portions of the group
and concealing certain di.stricts of it, revealing them again
by their witharawal later on. But as for the greater part of
its history, tbe group practically consisted of but one welldefined circular 
spot, there can be no doubt that the apparent
change of place from day to day corresponds very closely to
the real movement of the centre of the group upon the
solar surface. In this and in the second diagram the observed
positions for the first and last days at each appearance are not
given, as only a portion of the group was visible on some of
those occasions, and the centre of the part observed was therefore
not the true centre of the group.

The third group of long duration, that of August z, was a very
perfect example, of the type above described. The first faint
spots were seen on .August 2. By August 4 the long stream of
spots with a large spot at either end had fully formed ; and by
August I 1 the leader alone remained. During the next rotation
the group consisted only of one large circular well-defined spots.
At its third appearance this circular spot was preceded by a
number of small spots, but. after September 26 the entire group,
and especially the smaller spots, began to diminish, and the
group had disappeared before reaching the west limb. The most
striking feature in ·the history of the group was the rapid backward drift 
shown after its first appearance The forward move ..
ment during the· first: rotation, the r~t.rogression whilst on _the

# 2  
Old 08-29-2013
Try:
Code:
tr -d '\n' < file | fold -s -80

# 3  
Old 08-29-2013
Code:
All three groups were distinguished by the remarkable manner in which they moved
about  on  the  solar  surface, not only in longitude but also in latitude.  The
first group moved forward 5°"2 in longitude, and o 0 ·6 upward in latitude,  in·
the  four  days  following  its  formation.  In the fortnight that it was on the
further side of the Sun it moved forward 4°"0 in longitude, and 1°"1 downward in
latitude.  It  was  no'Y  a single circular spot, and remained nearly stationary
till its disappearance.  The second group, that of June 16, the principal  group
of  the  year,  showed  the most extraordin,ary drift, as the first diagram will
show.  Some of  the  minor  irregularities  are  probably  due  to  faculous  or
photospheric mat,ter drifting above portions of the group and concealing certain
di.stricts of it, revealing them again by their witharawal later on. But as  for
the  greater  part  of  its  history, tbe group practically consisted of but one
welldefined circular spot, there can be no doubt that  the  apparent  change  of
place  from  day  to  day  corresponds  very closely to the real movement of the
centre of the group upon the solar surface. In this and in  the  second  diagram
the  observed  positions  for the first and last days at each appearance are not
given, as only a portion of the group was visible on some  of  those  occasions,
and  the  centre  of  the part observed was therefore not the true centre of the
group.

The third group of long duration, that of August z, was a very perfect  example,
of  the  type  above described. The first faint spots were seen on .August 2. By
August 4 the long stream of spots with a large spot  at  either  end  had  fully
formed  ;  and by August I 1 the leader alone remained. During the next rotation
the group consisted only of one large circular well-defined spots.  At its third
appearance  this  circular  spot  was  preceded by a number of small spots, but.
after September 26 the entire group, and especially the smaller spots, began  to
diminish,  and the group had disappeared before reaching the west limb. The most
striking feature in ·the history of the group was the rapid backward drift shown
after  its  first  appearance  The  forward  move  ..   ment  during the· first:
rotation, the r~t.rogression whilst on _the

Im testing...
This was done by adding first line:.ll 80 above the text then using nroff:
Code:
nroff -e text

# 4  
Old 08-29-2013
If you're a vim user:

Code:
vi file
[SHIFT :]
type - set textwidth=80 [ENTER]
type - gg
type - gqG
[SHIFT :]
type - wq

# 5  
Old 08-29-2013
Hi.

I usually use:
Code:
NAME
       par - filter for reformatting paragraphs
...

DESCRIPTION
       par  is  a  filter  which  copies its input to its output, changing all
       white characters (except newlines) to  spaces,  and  reformatting  each
       paragraph.   Paragraphs are separated by protected, blank, and bodiless
       lines (see the TERMINOLOGY section  for  definitions),  and  optionally
       delimited by indentation (see the d option in the OPTIONS section).

...

If it is not in your system repository, it's available at: Par 1.52 - paragraph reformatter -- the web page contains an example of formatting to 44 characters, and pretty-printing comment lines (historical enclosures for an email reply) at the same time.

Best wishes ... cheers, drl
# 6  
Old 08-29-2013
Many systems provide an fmt utility that is designed for simple stuff like this. It also correctly handles indented paragraphs. Try man fmt to see if your system includes this utility. If it does, the command you want is:
Code:
fmt -w80 your_text_file_name

# 7  
Old 08-30-2013
Thank you all. I have done things with fmt, but also looking at the other ways you mentioned as well.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

How to know full width blade or half width blade?

HI, How do we figure out if the server is half blade server or full blade server? Anything we need to look at to know on this? thanks in advance (9 Replies)
Discussion started by: snchaudhari2
9 Replies

2. Shell Programming and Scripting

Compare a paragraph

I know this is a challenging, its about comparing a 3 paragraph, from a whois command, i want to print what is the data that is not unique, example below is the admin phone and techphone, the rest is the same.it will print the correct and wrong # whois google.com| sed -n '/Registry Registrant... (3 Replies)
Discussion started by: kenshinhimura
3 Replies

3. Programming

Changing double to character string in C++

I want to convert an double to a character string. I done the integer and float ones using itoa and ftoa. How can I do a similar thing with doubles? String::String ( const float f ) { char *cdata = ftoa (f); strcpy (STR, cdata.c_str ()); } String::String ( const double ... (1 Reply)
Discussion started by: kristinu
1 Replies

4. Shell Programming and Scripting

Remove new line character and add space to convert into fixed width file

I have a file with different record length. The file as to be converted into fixed length by appending spaces at the end of record. The length should be calculated based on the record with maximum length in the file. If the length is less than the max length, the spaces should be appended... (4 Replies)
Discussion started by: Amrutha24
4 Replies

5. Shell Programming and Scripting

Changing the character after the Underscore(_)

Hi Everyone, I am looking for a command that would do the following: 1) Change all the letters/words in a file to Lower case Letters/words. 2) Remove the Underscore (_) and Change the Character after the underscore (_) to an Uppercase letter. Example: File contains the below words: ... (5 Replies)
Discussion started by: filter
5 Replies

6. UNIX for Dummies Questions & Answers

Output text from 1st paragraph in file w/ a specific string through last paragraph of file w/ string

Hi, I'm trying to output all text from the first paragraph in a file that contains a specific string through the last paragraph in that file that contains that string. Previously, I was outputting just each paragraph with that search string with: cat in_file | nawk '{RS=""; FS="\n";... (2 Replies)
Discussion started by: carpenn
2 Replies

7. Shell Programming and Scripting

Changing one column of delimited file column to fixed width column

Hi, Iam new to unix. I have one input file . Input file : ID1~Name1~Place1 ID2~Name2~Place2 ID3~Name3~Place3 I need output such that only first column should change to fixed width column of 15 characters of length. Output File: ID1<<12 spaces>>Name1~Place1 ID2<<12... (5 Replies)
Discussion started by: manneni prakash
5 Replies

8. UNIX for Dummies Questions & Answers

Split a paragraph

Hi, Consider the following paragraph. This is line1. This is line2, This is last line. I need the output as 4:This is last line. i.e The line after the blank line should be displayed along with line number. I am a unix begineer.Any one please help me to solve this problem (3 Replies)
Discussion started by: Sekar1
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

Changing particular field in fixed width file

I have a fixed width file and i need to change 36th field to "G" in for about random 20 records? How can I do it? (4 Replies)
Discussion started by: dsravan
4 Replies
Login or Register to Ask a Question