Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Unexpected Behaviour from grepping Text File Post 302650419 by hexram on Saturday 2nd of June 2012 10:44:01 PM
Old 06-02-2012
Maybe this can help:
Code:
egrep ^...a.....n. /usr/share/dict/2of12.txt | head -5
advancement
apparition
arraignment
arrangement
audaciousness

I think that a period matches any character, including the record separator, in a regular expression.

---------- Post updated at 10:44 PM ---------- Previous update was at 10:28 PM ----------

Maybe THIS can help better:
Code:
egrep -w ...a.....n. /usr/share/dict/2of12.txt | head -5
advancement
apparition
arraignment
arrangement
bipartisan

The -w option stands for --word-regexp in egrep's man. Still, a period may match a record separator and thus you get ten character words OR eleven character words...

Now THIS may be quite what you wanted in the first place:
Code:
egrep -w '...a.....n[^^M]' /usr/share/dict/2of12.txt | head -5
advancement
arraignment
arrangement
derangement
devastating

The regular expression ends with a character range that means 'any character EXCEPT a record separator'; you may get it as a caret followed by a newline, both enclosed in brackets (open bracket, caret, control-V, newline, close bracket). Just a single tiny side-effect: I get 'self-advancement' somewhere down the list of results...

Last edited by hexram; 06-02-2012 at 11:58 PM.. Reason: Further clarification of my answer
This User Gave Thanks to hexram For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grepping Errors in a file

Hey All, I have to grep for an error from a file and get the results of errror in a different file...... But there should be no duplicate entries. Can anyone help me in giving a shell script for this This is file which contains pattern error which I am supposed to grep and put this in a... (4 Replies)
Discussion started by: achararun
4 Replies

2. Shell Programming and Scripting

Grepping text by providing line numbers.

Dear Friends, I have a flat file from which I want to grep line no. 7,10, 19 to 35, 37. How can it be done? Thank you in advance Anushree (6 Replies)
Discussion started by: anushree.a
6 Replies

3. Shell Programming and Scripting

Grepping log file

Dear All, I have a log file that is dislpayed as: <msg time='2009-10-14T05:46:42.580+00:00' org_id='oracle' comp_id='tnslsnr' type='UNKNOWN' level='16' host_id='mtdb_a' host_addr='UNKNOWN' version='1'> <txt>14-OCT-2009 05:46:42 *... (19 Replies)
Discussion started by: x-plicit78
19 Replies

4. Shell Programming and Scripting

Grepping file and returning passed variable if the value does not exist in file at all.

I have a list of fields that I want to check a file for, returning that field if it not found at all in the file. Is there a way to do a grep -lc and return the passed variable too rather then just the count? I am doing some crappy work-around now but I was not sure how to regrep this for :0 so... (3 Replies)
Discussion started by: personalt
3 Replies

5. AIX

Unexpected Behaviour with WPAR

Hello, We have a system running AIX 6.1.7.1. We have created a Workload Partition(wpar) on this system with wpar specific routing enabled. On wpar, we are running DNS (UDP/53) and syslog (UDP/514). en0: 1.1.1.1/255.255.255.0 NOT assigned to any wpar en1:... (0 Replies)
Discussion started by: 03sep2011
0 Replies

6. UNIX for Dummies Questions & Answers

mtime unexpected behaviour

Hi All, My requirement is to remove the more than 60 days files from Archive folder, so prepared this command. for files in `find /abc/Archive/<file_name_25032012.dat> -type f -mtime 61|xargs ls -lrt` do rm -f $files done I tested this command in both unix and informatica. In unix if files... (8 Replies)
Discussion started by: harris
8 Replies

7. Shell Programming and Scripting

Help with grepping data from a text file

Hello, I have a text file which contains a list of strings which I want to grep from another file where these strings occur and print out only these lines. I had earlier used the grep command where File1 was the file containing the strings to be grepped (Source File) and File2 the Target File... (4 Replies)
Discussion started by: gimley
4 Replies

8. Shell Programming and Scripting

Grepping text from one file in another file

Hello, I have a file with a large number of words each listed in sequential order one word per line. I want to search these words in another file which has the structure Both the files are large, but the words in the sourcefile are all available in the target file. I tried to grep... (2 Replies)
Discussion started by: gimley
2 Replies

9. UNIX for Advanced & Expert Users

[BASH] Getopts/shift within a function, unexpected behaviour

Hello Gurus :) I'm "currently" (for the last ~2weeks) writing a script to build ffmpeg with some features from scratch. This said, there are quite a few features, libs, to be downloaded, compiled and installed, so figured, writing functions for some default tasks might help. Specialy since... (3 Replies)
Discussion started by: sea
3 Replies

10. Shell Programming and Scripting

ksh Script, Reading A File, Grepping A File Contents In Another File

So I'm stumped. First... APOLOGIES... my work is offline in an office that has zero internet connectivity, as required by our client. If need be, I could print out my script attempts and retype them here. But on the off chance... here goes. I have a text file (file_source) of terms, each line... (3 Replies)
Discussion started by: Brusimm
3 Replies
Wordlist(3pm)						User Contributed Perl Documentation					     Wordlist(3pm)

NAME
Pod::Wordlist -- English words that come up in Perl documentation SYNOPSIS
None! Take that! ABOUT
Pod::Wordlist is used by Pod::Spell, providing a set of words (as keys in the hash %Pod::Spell::Wordlist) that are English jargon words that come up in Perl documentation, but which are not to be found in general English lexicons. (For example: autovivify, backreference, chroot, stringify, wantarray.) You can also use this wordlist with your word processor by just pasting "Pod/Wordlist.pm"'s content into your wordprocessor, deleting the leading Perl code so that only the wordlist remains, and then spellchecking this resulting list and adding every word in it to your private lexicon. CONTRIBUTING
You are welcome to send me your wordlists too, for possible incorporation into this wordlist. I can take them only in ASCII. Note that the scope of this file is only English, specifically American English. (But you may find in useful to incorporate into your own lexicons, even if they are for other dialects/languages.) COPYRIGHT AND DISCLAIMER
Copyright (c) 2001 Sean M. Burke. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This library 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. AUTHOR
Sean M. Burke, sburke@cpan.org [NB: This wordlist includes much of a wordlist that Mark-Jason Dominus gave me.] perl v5.8.8 2001-10-27 Wordlist(3pm)
All times are GMT -4. The time now is 10:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy