Sponsored Content
Top Forums Shell Programming and Scripting Print one sentence 40 to 50 words end with period in a file Post 302952125 by Aia on Thursday 13th of August 2015 11:38:55 PM
Old 08-14-2015
Quote:
Originally Posted by lxdorney
Thanks very much,

If you could explain little by little much better for the benefit of all the beginners.
sed -n '/\(.\{99,154\}[^0-9]\.\).*/ {s//\1/p;q}' test.txt
Sure.
If it matches the pattern within the slashes execute the actions within the block {}. The block actions are, replace empty for the first matched group and print and quit.

The Perl line does it, almost the same way but in a less cryptic way. $& is the pattern matched.

Let's add a beginning of line anchor `^' to prevent the possibility of matching from the middle of the line.
Quote:
Originally Posted by Aia
Code:
sed -n '/^\(.\{99,154\}[^0-9]\.\).*/ {s//\1/p;q}' test.txt

With Perl:
Code:
 perl -nle '/^.{99,154}\D\./ and print $& and last' test.txt


Last edited by Aia; 08-14-2015 at 12:50 AM..
This User Gave Thanks to Aia For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to find capital letter names in a file without finding words at start of sentence

Hi, I want to be able to list all the names in a file which begin with a capital letter, but I don't want it to list words that begin a new sentence. Is there any way round this? Thanks for your help. (1 Reply)
Discussion started by: kev269
1 Replies

2. Shell Programming and Scripting

Print starting 3rd line until end of the file.

Hi, I want to Print starting 3rd line until end of the file. Pls let me know the command. Thanks in advance. (1 Reply)
Discussion started by: smc3
1 Replies

3. UNIX for Dummies Questions & Answers

insert period at the end of each line

file1 contains: this is a test this is a test and only a test this is another test this is another test and only another only i'd like my file to look like this: this is a test. this is a test and only a test. this is another test. this is another test and only another only. (6 Replies)
Discussion started by: tjmannonline
6 Replies

4. Shell Programming and Scripting

Need help in script; [ script to control a sentence & its words ]

Hello friends, I am looking for any sed/awk/python script that can identify the position of a character or word in a file. Well, I prefer sed. <space> is a tab space since I actually dont know how to make the forum editor display a space as such. Sample text ----------- ... (3 Replies)
Discussion started by: frozensmilz
3 Replies

5. Shell Programming and Scripting

Trim the sentence containing colon and period to extract a word in between

Hello All , i am a newbie in korn shell scripting trying to trim a sentence that is parsed into a variable . The format of the sentence has three words that are separated from other by a " : " colon and "." period . Format of the sentence looks like ... (5 Replies)
Discussion started by: venu
5 Replies

6. Shell Programming and Scripting

print in incremental order a sentence

Dear help! I want to print The number i is number i let i=1 to 5 output should be like The number 1 is number 1 The number 2 is number 2 The number 3 is number 3 The number 4 is number 4 The number 5 is number 5 Would be gr8 if you mke this with awk Thanks (7 Replies)
Discussion started by: Indra2011
7 Replies

7. Shell Programming and Scripting

Print file end

Hello All, I have file names in a directory that ends this way File Names in the directory abc.log.1.txt abc.log.2.txt abc.log.3.txt I want to print the 1, 2 and 3 in the file names as the first column in my output, and some contents of the files as second and fourth columns. I wrote... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

8. Shell Programming and Scripting

match sentence and word adn fetch similar words in alist

Hi all, I have ot match sentence list and word list anf fetch similar words in a separate file second file with 2 columns So I want the output shuld be 2 columns like this (3 Replies)
Discussion started by: manigrover
3 Replies

9. Shell Programming and Scripting

awk Adding a Period at the end of a line

I started venturing in learning the art of using AWK/GAWK and wanted to simply added a period from line #11 to line #28 or to the end of the file if there is data. So for example: 11 Centos.NM 12 dojo1 13 redhat.5.5.32Bit 14 redhat.6.2.64Bit... (5 Replies)
Discussion started by: metallica1973
5 Replies

10. Shell Programming and Scripting

Add words in beginning , end after removing a word in a file

My file has the entries like below... /dev/sds /dev/sdak /dev/sdbc /dev/sdbu I want to make the file like below echo 1 > /sys/block/sds/device/rescan echo 1 > /sys/block/sdak/device/rescan echo 1 > /sys/block/sdbc/device/rescan echo 1 > /sys/block/sdbu/device/rescan (2 Replies)
Discussion started by: saravanapandi
2 Replies
STYLE(1)							   User commands							  STYLE(1)

NAME
style - analyse surface characteristics of a document SYNOPSIS
style [-L language] [-l length] [-r ari] [file...] style [--language language] [--print-long length] [--print-ari ari] [file...] style -h|--help style --version DESCRIPTION
Style analyses the surface characteristics of the writing style of a document. It prints various readability grades, length of words, sen- tences and paragraphs. It can further locate sentences with certain characteristics. If no files are given, the document is read from standard input. Numbers are counted as words with one syllable. A sentence is a sequence of words, that starts with a capitalised word and ends with a full stop, double colon, question mark or exclamation mark. A single letter followed by a dot is considered an abbreviation, so it does not end a sentence. Various multi-letter abbreviations are recognized, they do not end a sentence as well. A paragraph consists of two or more new line characters. Readability grades Style understands cpp(1) #line lines for being able to give precise locations when printing sentences. Kincaid formula The Kincaid Formula was developed for U.S. Navy training manuals; it ranges in difficulty from 5.5 to 16.3. It is probably best applied to technical documents, because it is based on adult training manuals rather than school book text. Dialogs (often found in fictional texts) are usually a series of short sentences, which lowers the score. On the other hand, scientific texts with many long scientific terms are rated higher, although they are not necessarily harder to read for people who are familiar with those terms. Kincaid = 11.8*syllables/wds+0.39*wds/sentences-15.59 Automated Readability Index The Automated Readability Index is typically higher than Kincaid and Coleman-Liau, but lower than Flesch. ARI = 4.71*chars/wds+0.5*wds/sentences-21.43 Coleman-Liau Formula The Coleman-Liau Formula usually gives a lower grade than Kincaid, ARI and Flesch when applied to technical documents. Coleman-Liau = 5.89*chars/wds-0.3*sentences/(100*wds)-15.8 Flesch Reading Ease formula Developed by Rudolph Flesch in 1948, the Flesch Reading Ease formula is based on school texts covering grades 3 to 12. It is wide- spread, especially in the USA, because it is computed easily and produces good results. The index ranges from 0 (hard) to 100 (easy). Standard English documents average around 60 to 70. Applying it to German documents gives bad results because of the dif- ferent language structure. Flesch Index = 206.835-84.6*syll/wds-1.015*wds/sent Fog Index The Fog index was developed by Robert Gunning. Its value is a school grade. The "ideal" Fog Index level is 7 or 8. A level above 12 indicates the writing sample is too hard for most people to read. Texts less than 100 words will not produce meaningful results. Note that a correct implementation would not count words of three or more syllables that are proper names, combinations of easy words, or made three syllables by suffixes such as -ed, -es, or -ing. Fog Index = 0.4*(wds/sent+100*((wds >= 3 syll)/wds)) Lix formula The Lix formula developed by Bjornsson from Sweden is very simple and employs a mapping table as well: Lix = wds/sent+100*(wds >= 6 char)/wds Index 34 38 41 44 48 51 54 57 School year 5 6 7 8 9 10 11 SMOG Grading The SMOG Grading for English texts was developed by McLaughlin in 1969. Its result is a school grade. SMOG Grading = square root of (((wds >= 3 syll)/sent)*30) + 3 It was adapted to German by Bamberger and Vanecek in 1984, who changed the constant +3 to -2. Word usage The word usage counts are intended to help identify excessive use of particular parts of speech. Verb Phrases The category of verbs labeled "to be" identifies phrases using the passive voice. Use the passive voice sparingly, in favor of more direct verb forms. The flag -p causes style to list all occurrences of the passive voice. The verb category "aux" measures the use of modal auxiliary verbs, such as "can", "could", and "should". Modal auxiliary verbs modify the mood of a verb. Conjunctions The conjunctions counted by style are coordinating and subordinating. Coordinating conjunctions join grammatically equal sentence fragments, such as a noun with a noun, a phrase with a phrase, or a clause to a clause. Coordinating conjunctions are "and," "but," "or," "yet," and "nor." Subordinating conjunctions connect clauses of unequal status. A subordinating conjunction links a subordinate clause, which is unable to stand alone, to an independent clause. Examples of subordinating conjunctions are "because," "although," and "even if." Pronouns Pronouns are contextual references to nouns and noun phrases. Documents with few pronouns generally lack cohesiveness and fluidity. Too many pronouns may indicate ambiguity. Nominalizations Nominalizations are verbs that are changed to nouns. Style recognizes words that end in "ment," "ance," "ence," or "ion" as nomi- nalizations. Examples are "endowment," "admittance," and "nominalization." Too much nominalization in a document can sound abstract and be difficult to understand. The flag -N causes style to list all nominalizations. The flag -n prints all sentences with either the passive voice or a nominalization. OPTIONS
-L language, --language language set the document language. -l length, --print-long length print all sentences longer than length words. -r ari, --print-ari ari print all sentences whose readability index (ARI) is greater than ari. -p passive, --print-passive print all sentences phrased in the passive voice. -N nominalizations, --print-nom print all sentences containing nominalizations. -n nominalizations-passive, --print-nom-passive print all sentences phrased in the passive voice or containing nominalizations. -h, --help Print a short usage message. --version Print the version. ERRORS
On usage errors, 1 is returned. Termination caused by lack of memory is signalled by exit code 2. ENVIRONMENT
LC_MESSAGES=de|en specifies the document language. The default language is en. LC_CTYPE=iso-8859-1 specifies the document character set. The default character set is ASCII. AUTHOR
This program is GNU software, copyright 1997-2005 Michael Haardt <michael@moria.de>. It contains contributions by Jason Petrone <jpetrone@acm.org> and Uschi Stegemeier <uschi@morwain.de>. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. HISTORY
There has been a style command on old UNIX systems, which is now part of the AT&T DWB package. The original version was bound to roff by enforcing a call to deroff. SEE ALSO
deroff(1), diction(1) Cherry, L.L.; Vesterman, W.: Writing Tools--The STYLE and DICTION programs, Computer Science Technical Report 91, Bell Laboratories, Murray Hill, N.J. (1981), republished as part of the 4.4BSD User's Supplementary Documents by O'Reilly. GNU
June 09, 2006 STYLE(1)
All times are GMT -4. The time now is 04:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy