Find word in a large file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find word in a large file
# 1  
Old 06-17-2012
Find word in a large file

Hi all

I am working on disallowing users to use easy passwords in pam.d setting on RHEL 5.7 and SuSe 11, and I was hoping to add more words into the current cracklib dict, so I use "echo" command to append new words into the file

I dont want to add the same words into the dict, I think I have too many redundant words now. I am using grep, but then grep is only going to show me so much, how do I find a word, sort it out alphabetically and pipe it to a file (that i can cross check so I dont end up adding same words into it)?

Code:
find /path/to/dir -name "itelli" <ok, im lost with sort,the only option i know is sort -nk and pipe> :(

Thanks!

---------- Post updated at 03:32 PM ---------- Previous update was at 03:22 PM ----------

Seems every time I post something here I get results on my own Smilie

Code:
find /path/to/dir -name "itelli" | sort -d >/tmp/words.txt

# 2  
Old 06-19-2012
Another approach could be to check that the wanted password match some complexity enforced rules (with a minimum number of uppercase , char, figures, punct character and so on ...)
# 3  
Old 06-19-2012
Hi HeadKandi,

A better answer would be as follows;

Code:
find /path/to/dir -name "itelli" | sort -du >/tmp/words.txt

As this will ensure that there are no duplicates in the file.

Regards

Dave
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find EXACT word in files, just the word: no prefix, no suffix, no 'similar', just the word

I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL. I need the whole word... (6 Replies)
Discussion started by: chicchan
6 Replies

2. Shell Programming and Scripting

How to find a particular word from a file

Hello Experts, I have to count the word like "RESULT_CODE: : -6" from the multiple files names like req.result_2_vqx-71144750.log for a particular date. Lets suppose the date is 10 OCT 2011. How I can do it with a single command in Solaris environment. Reagrds Oracle User (8 Replies)
Discussion started by: Oracle_User
8 Replies

3. Shell Programming and Scripting

Find word in file then get following characters

Hello, I have several xml files from which I want to find and return a particular string I want to locate the InId="00000008". Now that is inlcuded within a tag and ofcourse the number is different every time this is what I came up with given that after greping the line that contains the... (6 Replies)
Discussion started by: TasosARISFC
6 Replies

4. Shell Programming and Scripting

Find line number of bad data in large file

Hi Forum. I was trying to search the following scenario on the forum but was not able to. Let's say that I have a very large file that has some bad data in it (for ex: 0.0015 in the 12th column) and I would like to find the line number and remove that particular line. What's the easiest... (3 Replies)
Discussion started by: pchang
3 Replies

5. UNIX for Dummies Questions & Answers

find a word in a file, plus the next 6 characters?

I plan to use sed in a script to replace a string. My problem is the last 6 characters of the word to be replaced can be different each time, plus it's not always in the same spot on the line so I can't use cut or nawk to get the field. So I am looking for a way to find a certain word in a file,... (6 Replies)
Discussion started by: mikayla73
6 Replies

6. Shell Programming and Scripting

Find and analyze variable Strings in a large file.

Hi guys, I have multiple files (>5000) which I have in a folder. I read every file name and put it in a tmp variable "i" so that i can use it in the following task. I have a large .txt file (>50 MB) in which I want to find the variable "i" and the lines after this variable, so that I can use... (4 Replies)
Discussion started by: Ashitaka007
4 Replies

7. Shell Programming and Scripting

Find Exact word in file

Hi ALL, I want to search one string “20 “ i.e 20 with space. But my file where I am searching this “20 “ contain some data like 120 before image file truncated 220 Reports section succeeded 20 Transaction database .prd stopped 220 Reports section completed. When I search for the... (5 Replies)
Discussion started by: Jeevan Salunke
5 Replies

8. Shell Programming and Scripting

How to find a count of a word within a file

Hello, I'm looking for a wait to count the number of occurrences of a certain string of characters within a file. The file that I trying to parce has segments within the file that have a header and footer to each segment and I'm trying to do a count of the header string and compare it to a count... (9 Replies)
Discussion started by: bd_joy
9 Replies

9. Shell Programming and Scripting

find a word in a file, and change a word beneath it ??

Hi all, I have a file with lines written somewhat like this. aaaa ccc aa linux browse = no xssxw cdcedc dcsdcd csdw police dwed dwd browse = no cdecec (2 Replies)
Discussion started by: vikas027
2 Replies

10. UNIX for Dummies Questions & Answers

how to find a word repeated in a file

Hi everyone, I have a file in which a word is repeated more than one time and I want to know how many times it is repeated. ex: if i repeated word 'guru' in 10 lines I can get the o/p as: cat filename | grep -c 'guru'. How ever if the word is repeated more than one time, then how can I... (4 Replies)
Discussion started by: gurukottur
4 Replies
Login or Register to Ask a Question