Sponsored Content
Top Forums Shell Programming and Scripting Deleting a list of words from a text file Post 303033836 by Hawk4520 on Friday 12th of April 2019 08:34:45 AM
Old 04-12-2019
Quote:
Originally Posted by anbu23
Code:
awk ' {gsub("password|key|number|verify","") } 1 '  in.txt > out.txt

anbu23 looks like it is working. the problem is that it is also deleting sub strings and not just the word. in addition, is there any option to delete spaces that come after the deleted word?

say I have a sentence: The password and the key are safe in the vault - please verify.
and after the script I should get : The and are safe in the vault - please.

Quote:
Originally Posted by RudiC
Welcome to the forum.


How do you plan to deliver the "hundreds of words I want to delete" if you "don't want to put all of them inside the quotes of sed nor inside an external file"?
Thank you RudiC, and you are right - that makes no sense. what i meant is that i don't want to manually separate the words with whatever separator is needed - but guess I can just write a script for that.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting text from a file

Hi, In my korn shell script, I want to delete some particular text from a certain file...How can this be done? Is the below right? ed $NAMES << EOF echo "" > /dev/null echo "${x} = " > /dev/null echo "name = " > /dev/null echo "adress = " > /dev/null w q EOF (1 Reply)
Discussion started by: n8575
1 Replies

2. Shell Programming and Scripting

how to read all the unique words in a text file

How can i read all the unique words in a file, i used - cat comment_file.txt | /usr/xpg6/bin/tr -sc 'A-Za-z' '/012' and cat comment_file.txt | /usr/xpg6/bin/tr -sdc 'A-Za-z' '/012' but they didnt worked..... (5 Replies)
Discussion started by: aditya.ece1985
5 Replies

3. Shell Programming and Scripting

List all file names that contain two specific words.

Hi, all: I would like to search all files under "./" and its subfolders recursively to find out those files contain both word "A" and word "B", and list the filenames finally. How to realize that? Cheers JIA (18 Replies)
Discussion started by: jiapei100
18 Replies

4. UNIX for Dummies Questions & Answers

deleting words in list with more than 2 identical adjacent characters

Morning Guys & Gals, I am trying to figure out a way to remove lines from a file that have more than 2 identical characters in sequence.. So if for instance the list would look like ; the output would be ; I can't seem to get my head around perl (among many other... (7 Replies)
Discussion started by: TAPE
7 Replies

5. Shell Programming and Scripting

indexing list of words in a file

Hey all, I'm doing a project currently and want to index words in a webpage. So there would be a file with webpage content and a file with list of words, I want an output file with true and false that would show which word exists in the webpage. example: Webpage content data.html ... (2 Replies)
Discussion started by: Johanni
2 Replies

6. UNIX for Dummies Questions & Answers

Deleting Block of Text from a File

Hi I am looking for the way to delete the block of data for example original file line1 line2 line3 line4 line5 input file line2 line3 original file should contain line1 line4 line5 (3 Replies)
Discussion started by: rakeshkumar
3 Replies

7. Shell Programming and Scripting

I need to extract uique words from text file

Hello programmers, I need to create a list of unique words from a text file using PERL...may i have the code for that please? Thank you (1 Reply)
Discussion started by: alsohari
1 Replies

8. Shell Programming and Scripting

Search for words NOT in a text file

I have a long list of alphanumberic words (no spaces or characters) in file1.txt I need to check for the existance of each of the words from file1.txt against file2.txt and if the word is NOT in file2.txt, I need to know about it, either standard output or redirect to file3.txt For example:... (5 Replies)
Discussion started by: ajp7701
5 Replies

9. Shell Programming and Scripting

How to grep a log file for words listed in separate text file?

Hello, I want to grep a log ("server.log") for words in a separate file ("white-list.txt") and generate a separate log file containing each line that uses a word from the "white-list.txt" file. Putting that in bullet points: Search through "server.log" for lines that contain any word... (15 Replies)
Discussion started by: nbsparks
15 Replies

10. UNIX for Dummies Questions & Answers

Deleting words between every appearance of two words

Hi there, newbie there. I've been browsing the forums hoping to find a solution that answers a problem similar to what I need, but haven't had much luck. Any help would be greatly appreciated. Thanks! I need to delete a bunch of text between every appearance of two words in a really large file... (3 Replies)
Discussion started by: lendl
3 Replies
FOO(1)								     Commands								    FOO(1)

NAME
wordplay - anagram finder SYNOPSIS
wordplay string [-slxavnmd] [-w word] [-f wordfile] DESCRIPTION
wordplay is an anagram finder. What is an anagram? Well, let's turn to Merriam-Webster's Collegiate Dictionary, Tenth Edition: anagram: a word or phrase made by transposing the letters of another word or phrase. Each letter in the anagram must appear with the same frequency as in the original string. For example, the letters in the word "stop" can be rearranged to spell "tops" or "pots" or "sotp". "sotp" is not a word and is not of interest when generating anagrams. "stop" has four letters, so there are 24 ways to rearrange its letters. However, very few of the re- arrangements actually spell words. Wordplay, by using a list of words, takes a specified string of letters and uses the list of words to find anagrams of the string. By the way, "Wordplay" anagrams to "Rowdy Pal", and the program really can live up to that particular anagram. I have been able to come up with anagrams of most of my coworkers' names that are humorous, descriptive, satirical, or, occasionally, quite vulgar. OPTIONS
string String to be anagrammed. This should be seen to the program as a single argument. If you feel you must put spaces in the string, under UNIX, you will have to put backslashes in front of the spaces or just put the entire string in double quotes. Just leave the spaces out because the program throws them out anyway. -s Silent operation. If this option is used, the header and line numbers are not printed. This is useful if you want the output to contain only the anagrams. Use this option with the l (and x) option to generate a wordlist which can be piped or redirected. This option does not suppress error messages that are printed to stderr. Finding zero anagrams is not an error. -l Print list of candidate words before anagramming. This is the list of words that can be spelled with the letters from the specified string, with no letters being used more often that they appear in the input string. -x Do not perform anagramming. Use with l if you just want the candidate word list without anagrams. -a Allow anagrams containing two or more occurrences of a word. -v Consider strings with no vowels as candidate words and do not give up when there are no vowels remaining after extractions. -m Limit candidate word length to a maximum number of letters. Follow by an integer. m12 means limit words to 12 letters. m5 means limit them to 5 letters. -n Limit candidate word length to a minimum number of letters. Follow by an integer. n2 means limit words to 2 letters. n11 means limit them to 11 letters. -d Limit number of words in anagrams to a maximum number. Follow by an integer. d3 means no anagrams should contain more than 3 words. d12 means limit anagrams to 12 words. This is currently the option that I recommend to limit output, since an optimization has been added to speed execution in some cases when this option is used. -w Specify a word which should appear in all anagrams. This is useful if you already have a word in mind that you want in the ana- grams. This option should be specified at the end of the command, followed by a space and the word to use. -f Specify which word list to use. See example! This option should be specified at the end of the command, followed by a space and the alternate wordfile name. This is useful if you have other word lists to try or if you are interested in making your own custom- ized word list. New feature: Use a hyphen as the filename if the wordlist should be read from stdin. EXAMPLES
wordplay persiangulf Anagram the string "persiangulf" . wordplay anagramming -lx Print the list of words from the wordlist that can be spelled by using the letters from the word "anagramming". A letter may not be used more often than the number of times it occurs in the word "anagramming". No anagrams are generated. wordplay tomservocrow -n3m8 Anagram the string "tomservocrow" . Do not use words shorter than 3 letters or longer than 8 letters. wordplay persiangulf -ld3m10 -f /usr/share/dict/words Print the candidate words for the string "persiangulf". Print anagrams containing up to 3 words, without considering any words longer than 10 characters. Use the file "/usr/share/dict/words" rather than "words721.txt". wordplay soylentgreen -n3w stolen -f w2 Print anagrams of "soylentgreen" containing the word "stolen" and use the file "w2" as the wordlist file. Discard candidate words shorter than 3 characters. wordplay university -slx Print the candidate word list for the string "university". The output will consist of just the words. This output is more useful for redirecting to a file or for piping to another program. wordplay trymeout -s Anagram the string "trymeout" and print the anagrams with no line numbers. The header will not be printed. This is useful for pip- ing the output to another process (or saving it to a file to be used by another program) without having to parse the output to remove the numbers and header. wordplay trymeout -v Anagram "trymeout" as usual, but in case vowel-free strings are in the wordlist, consider them as possible candidate words. cat wordlist1 wordlist2 wordlist3 | sort -u | wordplay trymeout -f - Anagram "trymeout" and read the wordlist from stdin, so that, in this case, the three wordlists "wordlist1", "wordlist2", and "wordlist3" will be concatenated and piped into wordplay as the wordlist. The "sort -u" is there to remove duplicate words from the combined wordlist. NOTES
If the option specifiers are combined, as in "an7m7d5f" or "d3n5f", the f should come last, followed by a space and the word list file. The "w" option is used in the same manner. Limit the number of words to consider, if desired, using the n and m options, or better yet, use the d option to limit depth, when anagram- ming certain time-consuming strings. The program is currently optimized to speed execution in some cases when the d option is used. It is highly recommended that the "words721.txt" file distributed with the program be used, since many nonsense two and three-letter combi- nations that are not words have been eliminated. This makes the quality of the output slightly better and speeds execution of the program a slight bit. Any word list may be used, as long as there is one word per line. Feel free to create your own custom word list and use it instead. The word list does not have to be sorted in any particular way. FILES
/usr/share/games/wordplay/words721.txt Default word list file. DISTRIBUTION
This program was written for fun and is free. Distribute it as you please, but please distribute the entire package, with the original words721.txt and the readme file. If you modify the code, please mention my name in it as the original author. Please send me a copy of improvements you make, because I may include them in a future version. AUTHOR
Wordplay was written by Evans A Criswell <criswell@cs.uah.edu> This man page was written by Joey Hess <joeyh@debian.org> DECEMBER 1996 FOO(1)
All times are GMT -4. The time now is 07:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy