I've been struggling with an assignement for school for quite some time now and I decided to make a thread here. The goal of the script is to return all the words that can be created with a certain combination of letters that can be given as an argument for the shellscript. It's not necessary that the all these letters are used, but every letter can be used only once.
They also gave us some guidelines on how to make this script :
-> Save the first word (the combination of letters) in the hold space, so you can use it later on
-> For all other words you make a copy of the word in the pattern space, and separate it from the original worth with a verical line ( | )
-> Add the hold space to the pattern space
-> Use a loop in sed that erases both a letter from the duplicate as from the combination of letters till all the letters of the duplicate are used or till there are no corresponding letters
-> Only write the original version of the word (the word before the |) if all the letters behind the | are gone.
I know this is a lot of text, but here is some code to make up for it
This will turn into this :
And eventually :
I already found this part of the code :
I'm speak Dutch and the "woordenlijst.txt" document is a file which contains a couple of thousands of words.
There are still some faults in my code and I'd like to have them pointed out, or to get a better solution to solving this exercise.
I am learning SED and just following the shell scripting book, i have trouble understanding the grep and sed statement,
Question : 1
__________
/opt/oracle/work/antony>cat teledir.txt
jai sharma 25853670
chanchal singhvi 9831545629
anil aggarwal 9830263298
shyam saksena 23217847
lalit... (7 Replies)
Hi,
I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :-
./sample.sh: line... (12 Replies)
Hi!
I use an and grep to play Scrabble and other word games because it helps me practice regexes, or, as my friends would say, because I'm a cheater.
Anyway, I'm trying to work out how to write a regex that might do what I want, so let's see if I can explain it properly. Let's say we want to play... (3 Replies)
Hello and thx for reading this
I'm using sed to remove only the leading spaces in a file
bash-280R# cat foofile
some text
some text
some text
some text
some text
bash-280R#
bash-280R# sed 's/^ *//' foofile > foofile.use
bash-280R# cat foofile.use
some text
some text
some text... (6 Replies)