Sponsored Content
Top Forums Shell Programming and Scripting A little help using grep for anagram solving with BASH Post 302332340 by Donthommo on Thursday 9th of July 2009 04:19:35 AM
Old 07-09-2009
Homework? Ha no homework is quite a few years behind me!

Just an exercise I've set myself to revise my shell scripting because i've got interviews coming up.

Thanks for the reply, i'll take a proper look in the morning at the office, have to get to sleep soon.

If anyone has any thoughts on other variations on my idea that might work i'd like to hear them, i'll have another crack at finishing it in the next couple days when i'm done with loadrunner.

---------- Post updated at 09:19 AM ---------- Previous update was at 12:19 AM ----------

Thanks for the reply Perderabo, I tried running your script to see how it functioned but without success, I have not used sed before so not really ideal for helping me revise my scripting knowledge (which is of a fairly basic standard), but thankyou none the less for taking the time to reply.

What I was really after was just an idea of either an option for Grep that I had not thought of or suggestions on how one might go about removing the words from the final temp file that contain extra characters that are not wanted.

I.e. you want to find solutions for the letters 'nma' and you get:
Man
Manager
Mandate
etc etc

Of course the only actual one you want is 'Man' but the others appear because they still contain all the letters...

I'll see what I can come up with today but any thoughts/discussion on the subject is welcome and hopefully I can expand my knowledge a little by getting involved with the online community.

EDIT:


Came up with an idea, I'm going to try something along the lines of:

Load all the letters of the alphabet into an array.
Remove those contained in the user entered variable.
Remove any words from the word list that contain letters left in the array.

In theory this should just leave words contain all the input letters and no others. I still need to work out something for double letters but i'll work on that later.

This way also should take away the need to have it create so many temp files to ween down the results...

Last edited by Donthommo; 07-09-2009 at 05:42 AM..
 

6 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Solving the network collisions in Unix box

Hi, Anyone can u give me an idea to clear the network collisions in the unix box(Solaris and Linux)? NIC performance is very low, and it shows collisions, when issuing the command ifconfig -a in the production server. How can i rectify the network collisions in the box. Using netstat and lsof... (4 Replies)
Discussion started by: muthulingaraja
4 Replies

2. Shell Programming and Scripting

Lay person needs perl help solving error message

Hi, My name is Tex I am past 60 and in need of perl help. My hobby is genealogy and I am using a perl program to display my data on my web pages. I don't even know enough to know how to ask in the right way for the help I need. This program is written in perl it is open and has been updated... (2 Replies)
Discussion started by: tex
2 Replies

3. UNIX for Dummies Questions & Answers

Bash - CLI - grep - Passing result to grep through pipe

Hello. I want to get all modules which are loaded and which name are exactly 2 characters long and not more than 2 characters and begin with "nv" lsmod | (e)grep '^nv???????????? I want to get all modules which are loaded and which name begin with "nv" and are 2 to 7 characters long ... (1 Reply)
Discussion started by: jcdole
1 Replies

4. Homework & Coursework Questions

Solving heat equation using crank-nicolsan scheme in FORTRAN

! The one-dimensional PDE for heat diffusion equation ! u_t=(D(u)u_x)_x + s where u(x,t) is the temperature, ! D(u) is the diffusivity and s(x,t) is a source term. ! Taking D(u)= 1 and s(x,t)=0 gives ! u_t= u_xx ! uniform one dimensional region |x|<1 for t>0 ! uniform mesh size delta x=0.1 !... (1 Reply)
Discussion started by: watto1
1 Replies

5. Shell Programming and Scripting

Anagram finder based in Ascii values

Hello, i need some help with a programm i want to make, what i want to do is to make a dictionary and include some anagrams with it, and make the programm read the Ascii value of each word, and compare them with the anagrams and make the programm print the words that have the same Ascii value,... (1 Reply)
Discussion started by: jose2802
1 Replies

6. Shell Programming and Scripting

Shell script for solving the math question

Can such Puzzle solve through UNIX script? if yes, what could be the code? This has been solve in C language. we were trying to solve this through shell but could not because of not able to pass 1st argument with multiple value. we are not expert in unix scripting. Below is the puzzle John is a... (4 Replies)
Discussion started by: anshu ranjan
4 Replies
deroff(1)							   User Commands							 deroff(1)

NAME
deroff - remove nroff/troff, tbl, and eqn constructs SYNOPSIS
deroff [ -m [m | s | l] ] [-w] [-i] [ filename...] DESCRIPTION
deroff reads each of the filenames in sequence and removes all troff(1) requests, macro calls, backslash constructs, eqn(1) constructs (between .EQ and .EN lines, and between delimiters), and tbl(1) descriptions, perhaps replacing them with white space (blanks and blank lines), and writes the remainder of the file on the standard output. deroff follows chains of included files (.so and .nx troff commands); if a file has already been included, a .so naming that file is ignored and a .nx naming that file terminates execution. If no input file is given, deroff reads the standard input. OPTIONS
-m The -m option may be followed by an m, s, or l. The -mm option causes the macros to be interpreted so that only running text is output (that is, no text from macro lines.) The -ml option forces the -mm option and also causes deletion of lists associated with the mm macros. -w If the -w option is given, the output is a word list, one ``word'' per line, with all other characters deleted. Otherwise, the output follows the original, with the deletions mentioned above. In text, a ``word'' is any string that contains at least two let- ters and is composed of letters, digits, ampersands (&), and apostrophes ('); in a macro call, however, a ``word'' is a string that begins with at least two letters and contains a total of at least three letters. Delimiters are any characters other than letters, digits, apostrophes, and ampersands. Trailing apostrophes and ampersands are removed from ``words.'' -i The -i option causes deroff to ignore .so and .nx commands. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWdoc | +-----------------------------+-----------------------------+ SEE ALSO
eqn(1), nroff(1), tbl(1), troff(1), attributes(5) NOTES
deroff is not a complete troff interpreter, so it can be confused by subtle constructs. Most such errors result in too much rather than too little output. The -ml option does not handle nested lists correctly. SunOS 5.10 14 Sep 1992 deroff(1)
All times are GMT -4. The time now is 02:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy