Sponsored Content
Top Forums Shell Programming and Scripting Deleting a list of words from a text file Post 303033827 by Hawk4520 on Friday 12th of April 2019 07:28:17 AM
Old 04-12-2019
Deleting a list of words from a text file

Hello,

I have a list of words separated by spaces I am trying to delete from a text file, and I could not figure out what is the best way to do this.

what I tried (does not work) :
Code:
delete="password key number verify"
arr=($delete)
for i in arr
{
   sed "s/\<${arr[i]}\>[[:space:]]*//g" in.txt 
}
> out.txt

I have hundreds of words I want to delete, and I don't want to put all of them inside the quotes of sed nor inside an external file.
Please any suggestions how to solve the issue? any other efficient ways?
 

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
DtEditorInvokeSpellDialog(library call) 								   DtEditorInvokeSpellDialog(library call)

NAME
DtEditorInvokeSpellDialog -- display the DtEditor widget dialog for checking text for spelling errors SYNOPSIS
#include <Dt/Editor.h> DtEditorErrorCode DtEditorInvokeSpellDialog( Widget widget); DESCRIPTION
The DtEditorInvokeSpellDialog function displays the Spell dialog for the DtEditor widget. This dialog displays the list of unrecognized or misspelled words from the widget's text. Users can search for and replace misspelled words with the Spell dialog. The list of misspelled words is automatically generated by filtering the text for the DtEditor widget through the filter specified by the DtNspellFilter resource when DtEditorInvokeSpellDialog is called. For a complete description of the Spell dialog and the DtNspellFilter resource, see DtEditor(3). The widget argument specifies the DtEditor widget ID. For a complete definition of the DtEditor widget and its associated resources, see DtEditor(3). RETURN VALUE
Upon successful completion, the DtEditorInvokeSpellDialog function returns DtEDITOR_NO_ERRORS if the widget successfully executed the spell filter; otherwise, it returns one of the following: DtEDITOR_SPELL_FILTER_FAILED If it cannot successfully execute the filter specified by the DtNspellfilter resource. DtEDITOR_NO_TMP_FILE If it cannot create a temporary file in the directory returned by tmpnam(3S). SEE ALSO
Dt/Editor.h - DtEditor(5), DtEditor(3), tmpnam(3S). DtEditorInvokeSpellDialog(library call)
All times are GMT -4. The time now is 05:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy