Sponsored Content
Top Forums Shell Programming and Scripting grep multiple words in a single line Post 302280853 by just4fundoit on Tuesday 27th of January 2009 04:59:49 PM
Old 01-27-2009
Well you could do some thing like
awk '/ifile/&&/INPUT/ {print $0}' FILENAME|grep -v DATA
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

search multiple words using grep

Hi frnds i want to desplay file names that should be word1 and word2 ex : i have 10 *.log files 5 files having word1 and word2 5 files having only word1, i have used below command egrep -l 'word1|word2' *.log its giving all 10 files, but i want to display only 5... (20 Replies)
Discussion started by: pb18798
20 Replies

2. Shell Programming and Scripting

deleting blank line and row containing certain words in single sed command

Hi Is it possible to do the following in a single command /usr/xpg4/bin/sed -e '/rows selected/d' /aemu/CALLAUTO/callauto.txt > /aemu/CALLAUTO/callautonew.txt /usr/xpg4/bin/sed -e '/^$/d' /aemu/CALLAUTO/callautonew.txt > /aemu/CALLAUTO/callauto_new.txt exit (1 Reply)
Discussion started by: aemunathan
1 Replies

3. UNIX for Dummies Questions & Answers

Grep multiple strings in multiple files using single command

Hi, I will use below command for grep single string ("osuser" is search string) ex: find . -type f | xarg grep -il osuser but i have one more string "v$session" here i want to grep in which file these two strings are present. any help is appreciated, Thanks in advance. Gagan (2 Replies)
Discussion started by: gagan4599
2 Replies

4. UNIX for Dummies Questions & Answers

extract text between two words on a single line

Hi Guys, Can someone help me with a way to extract text between two words on a single line. For example if the file has below content I want to extract all text between b and f inclusive of b and f. Aparently sed does this but does it line by line and I guess it cannot read word by word. ... (11 Replies)
Discussion started by: krishnaux
11 Replies

5. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

6. Shell Programming and Scripting

Grep multiple words in a single file

Hello All, I'm a newbie/rookie in Shell scipting. I've done oracle export of a table using Export utility. When I do export, it generates 2 files. 1> .dmp file 2> .dmp.log file. In .dmp.log file I have to search for a sentence which goes like '0 records have been inserted' and then... (2 Replies)
Discussion started by: samfisher
2 Replies

7. Shell Programming and Scripting

Grep multiple words with not null value

Hi, I want to grep a file if any one (GH, IJ, KL) is not null. If it is null i dont want to pull anything. cat file | awk '{print ($1)}' Parameters are : AB=123;CD=456;EF=6789; cat file | awk '{print ($2)}' GH=456;IJ=789;KL=1011 eg: Contents in file: Parameters are :... (10 Replies)
Discussion started by: Neethu
10 Replies

8. Shell Programming and Scripting

Confused with grep for multiple words

Hi guys and gals, I have many files that contains many lines of data. I am trying to find a needle in a haystack in that I'm looking only for files that contain word1 AND word2. I'm using ... ... but this is finding files that contains word1 OR word2. No good for me. How can I grep to... (7 Replies)
Discussion started by: bbbngowc
7 Replies

9. Shell Programming and Scripting

sed command to grep multiple pattern present in single line and delete that line

here is what i want to achieve.. i have a file with below contents cat fileName blah blah blah . .DROP this REJECT that . --sport 7800 -j REJECT --reject-with icmp-port-unreachable --dport 7800 -j REJECT --reject-with icmp-port-unreachable . . . more blah blah blah --dport 3306... (14 Replies)
Discussion started by: vivek d r
14 Replies

10. UNIX for Beginners Questions & Answers

Display multiple words into a single td tag

awk 'BEGIN{print "<table>"} {print "<tr>"; for ( i=1;i<NF;i++) print " <td>" $I "</td>"; print "</tr>"} END{print " </table>"}' <file name > (6 Replies)
Discussion started by: Himanshu1
6 Replies
IFILE(1)							   User Commands							  IFILE(1)

NAME
ifile - core executable for the ifile mail filtering system SYNOPSIS
ifile [-b file] [-q|-Q] [-g] [-k] [-o] [-v num] [lexing options] file ... ifile -c -q|-Q [-T threshold] [-b file] [-g] [-k] [-o] [lexing options] file ... ifile [-b file] [-d folder] [-i folder|-u folder] [-g] [-k] [-o] [-v num] [lexing options] file ... ifile -r [-b file] DESCRIPTION
ifile is a mail filter client that uses machine learning to classify e-mail into folders/mail boxes. The algorithm that it uses is called Naive Bayes. Basically, naive bayes considers each document an unordered collection of words and classifies by matching the document dis- tribution with the most closely matching folder/mailbox distribution. OPTIONS
-b, --db-file=file Location to read/store ifile database. Default is ~/.idata -c, --concise equivalent of "ifile -v 0 | head -1 | cut -f1 -d". Must be used with -q or -Q. -d, --delete=folder Delete the statistics for each of files from the category folder -f, --folder-calcs=folder Show the word-probability calculations for folder -g, --log-file Create and store debugging information in ~/.ifile.log -i, --insert=folder Add the statistics for each of the files to the category folder -k, --keep-infrequent Leave in the database words that occur infrequently (normally they are tossed) -l, --query-loocv=folder For each of the files, temporarily removes file from folder, performs query and then reinserts file in folder. Database is not mod- ified. -o, --occur Uses document bit-vector representation. Count each word once per document. -q, --query Output rating scores for each of the files -Q, --query-insert For each of the files, output rating scores and add statistics for the folder with the highest score -T, --threshold=threshold When used with both -c and -q, output the two highest ranking categories if their score differs by at most threshold / 1000, which can be used to detect border cases. When used with -q only and any threshold > 0, output the score difference percentage. For example, ifile -T1 -q foo.txt might result in spam -15570.48640776 non-spam -18728.00272369 diff[spam,non-spam](%) 9.21 If so, then ifile -T93 -q -c foo.txt will result in foo.txt spam,non-spam whereas ifile -T92 -q -c foo.txt will result in foo.txt spam -r, --reset-data Erases all currently stored information -u, --update=folder Same as 'insert' except only adds stats if folder already exists -v, --verbosity=num Amount of output while running: 0=silent, 1=quiet, 2=progress, 3=verbose, 4=debug Lexing options: -a, --alpha-lexer Lex words as sequences of alphabetic characters (default) -A, --alpha-only-lexer Only lex space-separated character sequences which are composed entirely of alphabetic characters -h, --strip-header Skip all of the header lines except Subject:, From: and To: -m, --max-length=char Ignore portion of message after first char characters. Use entire message if char set to 0. Default is 50,000. -p, --print-tokens Just tokenize and print, don't do any other processing. Documents are returned as a list of word, frequency pairs. -s, --no-stoplist Do not throw out overly frequent (stoplist) words when lexing -S, --stemming Use 'Porter' stemming algorithm when lexing documents -w, --white-lexer Lex words as sequences of space separated characters If no files are specified on the command line, ifile will use standard input as its message to process. -?, --help Give this help list --usage Give a short usage message -V, --version Print program version Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options. FILES
~/.idata ifile database (default location). See FAQ included in ifile package for description of database format. AUTHOR
Jason Rennie <jrennie@csail.mit.edu> and many others. See the ChangeLog for the full list. EXAMPLES
Before using ifile, you need to train it. Let's say that you have three folders, "spam", "ifile" and "friends", and the following direc- tory structure: /--+--spam----+--1 | +--2 | +--3 | +--ifile---+--1 | +--2 | +--3 | +--friends-+--1 +--2 +--3 The following commands build the ifile database in ~/.idata (use the -d option to specify a different location for the database): ifile -h -i spam /spam/* ifile -h -i ifile /ifile/* ifile -h -i friends /friends/* The -h option strips off headers besides "Subject:", "From:" and "To:". I find that -h improves ifile's performance, but you may find oth- erwise for your personal collection. Note that we have made the argument to -i the same as the corresponding folder name. This is not necessary. The argument to -i can be any word you want to use to identify a category of e-mails. The argument to -i must not include space characters (including tab, feedline, etc.). At this point, your ~/.idata file should look something like this: spam ifile friends 662 1020 6451 3 3 3 jrennie 9 0:3 1:18 2:16 mindspring 6 1:7 2:5 make 9 0:5 1:3 yahoo 9 0:1 1:22 2:2 The first line is the space-separated list of folders. Their ordering specifies a numbering (spam=0, ifile=1, friends=2). The second line is a token count for each folder (e.g. 662 tokens observed in the three spam messages). The third line is an e-mail count for each folder (e.g. 3 e-mails for each of spam, ifile and friends). Each following line specifies statistics for a word. The format of a line is word age folder:count [folder:count ...] where folder is the folder number determined by the first line ordering. Folders with a count of zero are not listed. So, the line begin- ning with "jrennie" indicates that "jrennie" appeared 3 times in "spam" e-mails, 18 times in "ifile" e-mails and 16 times in "friends" e- mails. The age is the number of e-mails that have been processed since the word was added to the database. Very infrequent words are pruned from the database to keep the database size down. Now that you have a database, you might want to filter some e-mails. Say you have the following incoming e-mails: /--inbox--+--1 +--2 +--3 To find out what folders ifile thinks these e-mails belong in, run ifile -c -q /inbox/1 ifile -c -q /inbox/2 ifile -c -q /inbox/3 Let's say that 1 is about ifile, 2 is spam and 3 is from a friend. Assuming ifile does its job correctly, you'll see output like this: /inbox/1 ifile /inbox/2 spam /inbox/3 friends With such little training data, ifile is unlikely to get the labels correct, but you should get the idea :-) Now, if you move the e-mails to the folders suggested by ifile, you'll want to update the database accordingly. You can do this with the -i option, like before. Or, you can simply use -Q in place of -q above. This automatically adds the e-mail to the folder ifile suggests. Now, assume for a moment that e-mail 1 was actually spam. We've added 1 to ifile and put it in the ifile folder. We need to move it to the spam folder and update the ifile database accordingly. We can update the database with the following command: ifile -d ifile -i spam /inbox/1 This deletes the e-mail from "ifile" and adds it to "spam". SEE ALSO
Examples of how to use ifile together with procmail(1) and metamail(1) can be found in the directory /usr/share/doc/ifile/examples. ifile 1.3.4 November 2004 IFILE(1)
All times are GMT -4. The time now is 10:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy