Script to look for data in a file (not that simple) ...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to look for data in a file (not that simple) ...
# 1  
Old 02-14-2006
Error Script to look for data in a file (not that simple) ...

I'm looking for a script or program that would allow me to pass a pattern to it and give me locations on where text appears in a file. I wish it was that straight forward (I would use egrep or something)

Say I have the word in my text file "SUDAN" but my user does a search for "SUDANESE". Grep doesn't help me. The other way round would work
but I'm dealing with text files that are huge. I'm also looking for something
that could do a "sounds-like" too -- but not a major issue.

Can someone help me out? Is there a program out there or script I can
buy? O/S is SCO.

Thanks!
# 2  
Old 02-15-2006
a unix script solution

This you could achieve from a unix shell script.
Pls reach me at (emails not allowed - see the rules ) in case of any assistant.

Regards,
Manish Jha

Last edited by RTM; 02-15-2006 at 10:46 AM..
# 3  
Old 02-15-2006
I think you need to define what you need more precisely.
sudanese maps also to sudan? also to suda? sud?
that doesn't make sense to me.
Location? as in line number?
sounds like perl to me. There is a perl soundex module.
# 4  
Old 02-15-2006
Quote:
Originally Posted by bigearsbilly
I think you need to define what you need more precisely.
sudanese maps also to sudan? also to suda? sud?
that doesn't make sense to me.
Location? as in line number?
sounds like perl to me. There is a perl soundex module.
It could be but I'm not very experienced with Perl.
I want to be able to pass a string to a script that would
look for data in a file that looks almost like the string that
was passed.

I pass this string to the script: Smithsonian
Somewhere in my file there is a line: Dobbs Smith

I want to have the script to be able to send the whole line to standard
output. (Kind of like what egrep does)

I have a soundex function in my database. I'm going to use that first
and see what happens.

I would still like to hear if there are some other options as well.
Smilie (If I was able to explain myself clearly)

Thanks!
# 5  
Old 02-15-2006
hmm! methinks this is quite non-trivial.

it's definitely not a shell script!
maybe, if you have a soundex,

1. get the search string
2. run the soundex on /usr/dict/words to get a list of possibles
3. then grep the target data on *that* list

? I think that would be a simple-ish method that may just work.
maybe Smilie
# 6  
Old 02-15-2006
needs work!

Code:
#!/usr/bin/perl -ws

use Text::Soundex;

@ARGV = </usr/dict/words>;
@list = <> ;

$search=soundex($search) or die "\n$0 -search=string\n" ;
print "Looking for: $search\n" ;

foreach (@list) {

     print if soundex($_) eq $search;
}


Code:
$  soundex.pl -search=smithsonian
Looking for: smithsonian
saints
sands
sandstone
sandwich
sandwiches
scantiest
scents
schematic
schematically
schematics
scientist
scientists
senates
sends
shanties
smiths
smoothes
smoothest
smudge
snatch
snatched
snatches
snatching
snouts
somatic
sonnets
soundest
sounds
syndicate
syndicated
syndicates
syndication
syntactic
syntactical
syntactically
syntax
syntaxes
synthesis
synthesize
synthesized
synthesizer
synthesizers
synthesizes
synthesizing


Last edited by bigearsbilly; 02-15-2006 at 04:39 PM..
# 7  
Old 02-16-2006
I'll try it out and see what happens!

Thank you!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

In PErl script: need to read the data one file and generate multiple files based on the data

We have the data looks like below in a log file. I want to generat files based on the string between two hash(#) symbol like below Source: #ext1#test1.tale2 drop #ext1#test11.tale21 drop #ext1#test123.tale21 drop #ext2#test1.tale21 drop #ext2#test12.tale21 drop #ext3#test11.tale21 drop... (5 Replies)
Discussion started by: Sanjeev G
5 Replies

2. Shell Programming and Scripting

HELP simple script to find e-mail address on a file

Hello guys, im new to to unix/linux i have a text file like this: person1@test.com iisiiasasas person2@test.com 123w2 3233 sajsja person3@test.com jsajjsa sajsjasaj person4@test.com I want to extract only e-mail address and get rid of all other stuff, i want an output like this ... (4 Replies)
Discussion started by: RazorMX
4 Replies

3. Homework & Coursework Questions

Create a simple bash backup script of a file

This is the problem: Write a script that will make a backup of a file giving it a ‘.bak’ extension & verify that it works. I have tried a number of different scripts that haven't worked and I haven't seen anything really concise and to the point via google. For brevity's sake this is one of the... (4 Replies)
Discussion started by: demet8
4 Replies

4. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

5. Shell Programming and Scripting

Simple shell script to find and print data

Hi, I have a log file containing data on emails sent. Looks a bit like this for one email: Content-Type: text/plain; charset="UTF-8" Date: 12 Jun 2008 14:04:59 +0100 From: from@email.com Subject: xcf4564xzcv To: recip@email.co.uk Size = 364 Jun 12 14:04 smtp_234sldfh.tmp I need to... (5 Replies)
Discussion started by: terry2009
5 Replies

6. Shell Programming and Scripting

Simple open remote file script

I use Rsync to copy files to a remote folder in a command like this rsync -aNPHAXxrvh --protect-args --fileflags --force-change --delete $file user@remotehost:/Volumes/backup That works great with passwordless key exchange ;) Now I'm trying to open a remote file using this command ssh -q... (5 Replies)
Discussion started by: elbombillo
5 Replies

7. UNIX for Dummies Questions & Answers

running a simple script file with multiple commands

I'm trying to run a script file with multiple commands that I would normally type into the command line. The commands are: #!/bin/bash diff Test1.o0 /usr3/ronelso4/Desktop/verificationKPC/Test1.o0 > differences2 diff Test1a.o0 /usr3/ronelso4/Desktop/verificationKPC/Test1a.o0 >> differences2... (1 Reply)
Discussion started by: knelson
1 Replies

8. Shell Programming and Scripting

Simple script to modify kickstart file

Hi, I would like to create a script so that it will ask me the following: 1) What is the ip address? 2) What is the gateway address? 3) What is the hostname? and then put the answer to the below kickstart file (kickstart.cfg) Here I included the kickstart.cfg: # Kickstart file... (9 Replies)
Discussion started by: beeloo
9 Replies

9. Shell Programming and Scripting

Simple Find file Script.....

Im trying to make a very simple find the first file with the .zip extension in a specific folder and open that file. The folder path and file name will vary every-time and it may contain spaces. If I try to look For this example the folder directory is /Users/username/Desktop/testfolder/abc... (6 Replies)
Discussion started by: elbombillo
6 Replies

10. Shell Programming and Scripting

Simple file checking script

Hi, I have a really, what I hope is, simple question. I'm looking for a simple way to see whether a file exists or not and then perform an action based on whether it exists or not. An example of what I tried is as follows: if then { echo "File mysql exists" ... (1 Reply)
Discussion started by: _Spare_Ribs_
1 Replies
Login or Register to Ask a Question