Thanks rdrtx1, RudiC and R. Singh for awk and sed examples. Working great! The sed example puts letters in array and avoids overwriting by &/; which the awk example does by next.
Good point Don about "h" words. Awk example works by adding:
and "a hose" etc. is maintained. But modifying sed example:
prints: an an hour
No. In awk /^["hour"]/ will select any line starting with ", starting with h, starting with o, starting with u, or starting with r. What you want is something considerably more complex like:
for US English, or:
for UK English. Note that I think this will correctly handle cases like:
but I am not at all sure that this list of exceptions is anywhere close to complete.
-----------------------
Update: The above does not take herb into account. And, you can't always tell how to handle it just from the spelling. Some men's names (both Herb and Herbert) have a silent H and some have a verbalized H. Since your code only processes lower case letters, maybe you don't care about proper names.
Last edited by Don Cragun; 08-01-2016 at 11:09 PM..
Reason: Add note and correct to check for heir, honor, and hour at end of input line.
This User Gave Thanks to Don Cragun For This Post:
I want to print out a directory listing, then append ] to the end of each line. I'm trying to create a list of Wiki links based on folder listings that i can just copy and paste without having to edit 100's of file listings.
Using sed i've figured out to do something like this:
sed... (4 Replies)
Hi,
I am trying to add a blank line between sets of replicate values. I have been trying to use
uniq -D -f4 input.txt > output.txt
The input is like
V2-1.0 -1.0 5500.00 4162.00 529976.06030125.0 1997A
V2-1.0 -1.0 6000.00 4285.00 ... (6 Replies)
Hello everyone, I've suddenly gotten very interested in sed and awk (and enjoying it quite a bit too) because of a large conversion project that we're working on. I'm currently stuck with a very inefficient process for processing text blocks. I'm sure someone here should be able to easily point out... (2 Replies)
hi all,
i have some functions in a text file
ex:"int* function(int param)"
i find this functions with the command "var=grep -o "int**(*)" textfile"
i tested this regex and it's working
now i want to take only the name of the function from the grep result,
in my example "function"
how can... (1 Reply)
Hello:
(exp) : match "exp",the matched text is stored in auto named arrays.
How can I get the matched text ? What is the name of the auto named arrays on linux shell ? (4 Replies)
hi dudes, I nee you kind assistance, I have to find the matched numbers from 2 text files and output of matched numbers should be in another text file..
I do have text files like this , for example
File 1
787
665*5-p
5454
545-p
445-p
5454*-p
File 2
5455
787
445-p
4356
2445
144
... (3 Replies)
Hi,
I have a file with email header information. I would like to change the Subject line.
Subject: ** PROBLEM Host Alert: server.domainname is DOWN **
I'd like to change this line such as to look,
Subject: serverID ACK Fw: ** PROBLEM Host Alert: server1.domainname is DOWN**
How can I... (2 Replies)
Hi everyone. I need to change a script (ksh) so that it will grep on the 1st 2 letters in the second column of a 5 column file such as this one:
192.168.1.1 CAXY0_123 10ABFL000001 # Comment
192.168.1.2 CAYZ0_123 10ABTX000002 # Comment
192.168.2.1 FLXY0_123 11ABCA000001 ... (4 Replies)
I need to search a string for some specific text which is no big deal using grep. My problem is when the search fails to find the text. I need to add text like "na" when my search does not match.
I have tried this command but it does not work when I put the command in a loop in a bash script:
... (12 Replies)
I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty.
I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)