04-28-2008
PERL: Searching for a string in a text file problem
Looking for a bit of help. I need to search for a string of words, but unfortunately these words are located on separate lines.
for example the text output is:
United
Chanmpions
Ronaldo
Liverpool
Losers
Torres
and my script code is
print("DEBUG - checking file message");
while (<FILE>){
$line = $_;
if($line =~ /United/ ){
print("\nAbout to send email\n");
sendEmail($contacts,
"",
"Monitoring",
"\nPlease be aware that there is a problem.",
"",
"");
}
the above script will send out an e-mail when it locates United, but I need to send out an e-mail when it gets United Champions Ronaldo.
I thought something like
if($line =~ /United/n Champions/n Ronaldo/)
But no luck.
Any suggestions as to how to go about this.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi!
I'm new here and glad to meet everyone!
I've been wrestling with a problem lately however! How do I recursively (recursive means to keep going through the subdirectories until no more are there) search a bunch of textfiles in a long directory structure for a specific string.. but only... (1 Reply)
Discussion started by: skwadim
1 Replies
2. Shell Programming and Scripting
Hi All,
I need to search for a string in a file that I've opened and base a decision on the result. The logic is this:
"if the word 'Shared' appears on the first line then
do this on the whole file
else
do this on the whole file
"
The code I currently have isn't working:... (4 Replies)
Discussion started by: pondlife
4 Replies
3. Shell Programming and Scripting
Hi,
Need to extract a string from one file and search the same in other files.
Ex:
I have file1 of hundred lines with no delimiters not even space.
I have 3 more files.
I should get 1 to 10 characters say substring from each line of file1 and search that string in rest of the files and get... (1 Reply)
Discussion started by: mohancrr
1 Replies
4. Shell Programming and Scripting
Hi,
I'm very new to UNIX scripting and find quite difficult to understand simple UNIX syntax. Really appreciat if somebody could help me to give simple codes for my below problems:-
1) I need to search for a string "TTOH 8031950001" in a files which filename will be "*host*'. For example, the... (3 Replies)
Discussion started by: cuji
3 Replies
5. Shell Programming and Scripting
hello, i'm a novice on bsh scripting so thanks for any help here
basically i have a shell var $x that looks like this
> echo $x
nabc1234:!:73394:17155:Gary Mason:/home/garym:/bin/ksh
and i'm trying to keep the first 8 characters and the text from the 4th : to the 5th :
i've been trying... (9 Replies)
Discussion started by: sasglm
9 Replies
6. Shell Programming and Scripting
Hi Forum.
Is there a quick way to do the following search/replace within a block of data? I tried to google the solution but didn't really know what to look for.
I have the following text file (I want to search for a particular string "s_m_f_acct_txn_daily_a1" and replace the... (5 Replies)
Discussion started by: pchang
5 Replies
7. Shell Programming and Scripting
without using conventional file searching commands like find etc, is it possible to locate a file if i just know that the file that i'm searching for contains a particular text like "Hello world" or something? (5 Replies)
Discussion started by: arindamlive
5 Replies
8. Shell Programming and Scripting
Hi
I would like to read a file using perl and search for a string (last entry). Then read that into an array and do further grep
File content for ex:
comp=a,value=30,runtime=12,type=lic
comp=d,value=15,runtime=2,type=lic
comp=a,value=90,runtime=43,type=lic... (1 Reply)
Discussion started by: vivek_damodaran
1 Replies
9. Shell Programming and Scripting
Hi all,
i have a generated report in unix in the following command like
input.txt
47.85,10
0124,42.35,8
0125,3.5,2
the input file format is fixed
I need the my output file with append text as below
output.txt
0124 amount:42.35
0125 amount:3.5
0124 count : 8
0125... (34 Replies)
Discussion started by: hemanthsaikumar
34 Replies
10. Shell Programming and Scripting
I have two files
1. input.txt
2. keyword.txt
input.txt has contents like
.src_ref 0 "call.s" 24 first
0x000000 0x5a80 0x0060 BRA.l 0x60
.src_ref 0 "call.s" 30 first
0x000002 0x1bc5 RETI
.src_ref 0 "call.s" 31 first
0x000003 0x6840 ... (2 Replies)
Discussion started by: acdc
2 Replies
LEARN ABOUT DEBIAN
doctorj
DOCTORJ(1) DOCTORJ(1)
NAME
doctorj - Javadoc analyzer and spell-checker
SYNOPSIS
doctorj [--emacs] [--warning=LEVEL] [--tabwidth=NUM]
[--dictionaries=LIST] [--verbose] {FILE...}
DESCRIPTION
doctorj is an application to analyze Javadoc comments against Java code, verifying its integrity and format. It also spell-checks Javadoc
comments.
OPTIONS
--emacs
Whether to list violations in Emacs form, i.e., a single line of the form:
8:48:9:4: An error occurred on this line.
By default, violations are displayed in ``long form'', showing the context.
--warning=LEVEL
Sets the warning level, which by default is -1, meaning that only errors are reported. A warning level of 0 means that Javadoc for
public or abstract items (classes, interfaces, methods, constructors, and fields) will be checked. A warning level of 1 will result
in the addition of checking of protected-access items; 2 is for package-access items, and 3 will check all items.
--tabwidth=NUM
Sets the number of spaces to use for alignment with tabs. By default, this value is 4.
--dictionaries=LIST
Sets the dictionaries (word lists) to use for spell-checking. LIST is a comma-delimited string of paths to the word list files. By
default, doctorj uses the word list at /usr/share/doctorj/words.LOCALE, where LOCALE is of the standard Java form. doctorj is dis-
tributed with three word lists: words.en_CA (Canadian English), words.en_UK (United Kingdom English), and words.en_US (United States
English).
--verbose
Produces debugging output. Note that this signficantly impedes performance.
FILE Specifies the files to check. If the argument specified is a directory, all files ending in ``.java'' under that directory will be
analyzed.
EXAMPLES
To check a single file:
% doctorj String.java
To check multiple files:
% doctorj String.java StringBuffer.java Object.java
To check all files below a directory:
% doctorj /proj/app/src
To run at the maximum warning level:
% doctorj --warning=4 .
To specify a different dictionary:
% doctorj --dictionaries=/usr/share/dict/words .
CONFIGURATION
$HOME/.doctorjrc
The run-control file, of the form:
emacs: true
warning: 4
tabwidth: 8
dictionaries: /usr/share/dict/words,/home/me/etc/terms
verbose: false
Dictionary (word list) files contain one word per line, for example:
adaxial
cepaceous
sabaton
vespiaries
AUTHOR
Jeff Pace<jpace@incava.org>
The DoctorJ web site is at http://www.doctorj.org.
BUGS
Bugs and issues should be reported at the SourceForge.net project site: http://www.sf.net/projects/doctorj
SEE ALSO
java(1), javadoc(1)
COPYRIGHT
Copyright (c) 2002, Jeff Pace.
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the terms of the GNU Lesser General
Public License: http://www.gnu.org/licenses/lgpl.html
DOCTORJ(1)