06-15-2017
Thank you Don. I corrected "cnt[$5]" to "c[5]" and it worked (on bash in OS X 10.6).
---------- Post updated at 02:08 PM ---------- Previous update was at 02:03 PM ----------
Thanks Rudi. That works great. So far I avoided learning awk except for the simplest tasks, because the flow control in snippets I've grabbed here and there is so terse (to me it appears non-existent in your and Don Cragun's solutions). But I've just got hold of Dale Dougherty's book on sed and awk, and I'll be learning how this works now. (Where's the loop for reading the file on the first pass? Where's the conditional print? Etc... I can already see from looking over Dougherty's book that the answers are there, no need to answer.)
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
i have a file a.txt and following is only one portion.
I want to search <branch value="/dev36/AREA/" include="yes"></branch> present in between
<template_file name="Approve External" path="core/approve/bin" and </template_file>
where the no of lines containing "<branch value= " is increasing ... (2 Replies)
Discussion started by: millan
2 Replies
2. Shell Programming and Scripting
My sql file xyz_abc.sql in this file there are multiple sql block in this block I need to find the following block
rem Subset Rows (&&tempName.*)
CREATE VIEW &&tempName.* AS
SELECT *
FROM &&tempName.*
WHERE f is not null
and replace with following code
rem Subset Rows... (9 Replies)
Discussion started by: Zaheer.mic
9 Replies
3. Shell Programming and Scripting
Hi,
I would like to know how to solve one of my problems using expert unix commands.
I have a file with occasional blank lines;
for example;
dertu
frthu
fghtu
frtty
frtgy
frgtui
frgtu
ghrye
frhutp
frjuf
I need to edit the file so that the file looks like this; (10 Replies)
Discussion started by: Lucky Ali
10 Replies
4. UNIX for Dummies Questions & Answers
Hello all, new to unix and have just found the forum.
I think I will be here quite often, and hope that in time i will be able to provide soem help, role on not being a newbie anymore :)
I have a question which iI am hoping someone could help me with.
If i have a file with lines in in thus... (8 Replies)
Discussion started by: grom
8 Replies
5. Shell Programming and Scripting
i have a file containing over 1 million records,and i want to print about 300,000 line containing a some specific words.
file has content.
eg
1,rrt,234
3,fgt,678
4,crf,456
5,cde,drt
6,cfg,123
and i want to print the line with the word fgt,crf
this is just an example,my file is so... (2 Replies)
Discussion started by: tomjones
2 Replies
6. UNIX for Dummies Questions & Answers
Hi Experts,
I have a file which contains some text. i need to print the word next to a given keyword. Please help.
Ex: test.txt
=====================
NEXT HOST
=====================
AEADBAS001
access-list 1 permit xxxxxxxxxxxxxx
ip access-list extended BLA_Outgoing_Filter... (6 Replies)
Discussion started by: mwrg
6 Replies
7. Shell Programming and Scripting
i need to get least lines of file after last word TEST in file, and send that lines to mail
example of file structure:
TEST 10.10.2010
jdfjdnjfndjfndnfkdk
djfjdnfjkdjkfnjkdfk
jdfjdjfnjdjnfjkdnfjk
TEST 11.10.2010
jdjfnjdnfdkdfjdfjdnk
jdnfjdnjkfndnfjdnfjk
fjdnfjkndnfdfnjdnfjk
TEST... (6 Replies)
Discussion started by: waso
6 Replies
8. Shell Programming and Scripting
Hi All,
I want to read all lines after a perticular string {SET UP VALUES}apprears in the file.
SET UP values contains direcory, number of days and file type.
Step1: Read all lines below SET UP VALUES string.
Step2: If set up values are not present in each record then read from default... (4 Replies)
Discussion started by: Nagaraja Akkiva
4 Replies
9. UNIX for Advanced & Expert Users
Hi ,
i have a file with data as below.This is same file. But actual file contains to many rows.
i want to search for a string "Field 039 00" and delete that line and previous 3 lines in that file.. Can some body suggested me how can i do using either sed or awk command ?
Field 004... (7 Replies)
Discussion started by: vadlamudy
7 Replies
10. UNIX for Beginners Questions & Answers
Guys i need an idea for one logic..in shell scripting am struggling with a logic...So the thing is... i need to search for a word in a huge log file and i need to continue to print few more lines from that line and the consecutive line has to end when it finds the line with date..because i know... (1 Reply)
Discussion started by: Prathi
1 Replies
Cone(C)
LEAF(1) Cone: COnsole Newsreader And E LEAF(1)
NAME
leaf - Lightweight Editor of Ascii(and more) Files
SYNOPSIS
leaf [-f] [-d dictionary] [+n] [filename]
USAGE
leaf is a simple console text file editor, with paragraph word-wrapping and spell checking. leaf is based on the text editor in the Cone
mail reader and composer. leaf opens filename, positioning the cursor on the first line, or line #n, if specified.
This is not really the best editor for program sources. leaf is meant to be used as a quick editor for writing short notes and memos. As
text is typed, words will automatically flow to wrap within a typical 80-character terminal display, even on larger display (due to leaf's
heritage as an editor for E-mail messages, which are traditionally formatted to fit an 80-character display). Word wrapping is "lazy": only
long text lines are wrapped. Short text lines are not folded together. Individual paragraphs are separated by blank lines of text. Press
CTRL-J to optimally rejustify the paragraph under the cursor. The bottom two lines on the screen list which keys to press for other
functions.
Flowed text
The -f option enables "flowed text" formatting convention. Plain text files have no explicit means for joining multiple lines into logical
paragraph. Each line of text is an individual line, and a blank line marks the end of a paragraph.
In a "flowed text" formatted file, each line in a paragraph except the last one ends with a space character. This makes no visual
difference, it's just a marker that this line should be merged with the next line. The last line in the paragraph does not end in a space
character.
The trailing space character is logically removed from each flowed line, and all flowed lines are merged into a logical paragraph that can
be adjusted to any display width. It's important to note that text written in non-ideographic languages, where individual words are
separated by spaces, will have two space characters at the end of every line: the space character that separates the last word on the line
from the first word on the next line, and the a second space character that marks the line as a flowed line.
Because the trailing space marking a flowed line is logically removed, without the second space character there will not be a logical space
between the two words, and if the paragraph's width is adjusted for display the two words may get combined together.
The -f option puts leaf into flowed text mode, removing spaces from each flowed line of text in an opened file. A flowed line is marked on
the screen with a "<" character in the right margin (or a small "next line" character on a UTF-8 display). When saving a file leaf
automatically adds a trailing space to each line that's marked as flowed.
The flowed text mode stays in effect for each file opened in leaf. When opening another file, press CTRL-F to turn flowed mode on or off
for the next file. This change stays in effect until it gets toggled again.
Pressing CTRL-J optimally rejustifies the text in flowed text mode. leaf heuristically determines the start and the end of the paragraph,
readjusts the width of the paragraph, and marks each line as flowed, except the last paragraph line. leaf uses a unicode-based algorithm
for determining whether the last character line needs a space character, in addition to the flowed space marker.
Note
leaf is frequently used to edit plain text email message content. Because email messages assign some semantical meaning to lines of
text that start with spaces or ">" characters, CTRL-J will not rejustify lines of text that begin with a ">" or a space. These lines
will be considered paragraph boundaries, in addition to blank lines.
Spell checking
The -d option sets the name of the dictionary used for spell checking (overriding the default spell checking dictionary set by the
DICTIONARY environment variable). +n sets the initial cursor position to line #n.
SEE ALSO
emacs(1), vi(1)
AUTHOR
Sam Varshavchik
Cone(C) 04/04/2011 LEAF(1)