General :: Grep 2 Words At The Same Time?
Sep 9, 2010I want to grep any line with "john" or "jack". How to do that? I tried
grep john | grep jack
but it didn't work
I want to grep any line with "john" or "jack". How to do that? I tried
grep john | grep jack
but it didn't work
I need to grep a dictionary file.Only the words that contain 2 or more z's and only 1 b needs to be listed.
View 1 Replies View RelatedI'm trying to use grep to find the words in the dictionary that contain the letters "th" and the letter m.
I tried grep 'th m*.' Desktop/Dictionary/words(Thats where the destined dictionary word document is located)
grep 'th' Desktop/Dictionary/words works but only for the words with th. I have no idea of what expression to use to make it a unionized expression with m
So theres this command
Code:
man -k mail
Which lists commands that contain the keyword "mail" in their description.I want the output of this command in less and the words highlighted by grep. Something like
Code:
man -k mail | grep mail | less
The command doesn't work, how do I fix it?
I am trying to use grep to only tell me files that include both words matching in a pattern file. However when i specify:
grep -f <pattern file> <file>
It pulls out anything that matches one or the other.
Not both.
how to get it to match AND not OR.
I'm trying to write a script that will either tail or watch /var/log/messages for the words
PHP Code:
signal Gone into alarm state
From this line below.
I would then like the script execute:
And have run at start up.
I'm stuck with grep-ping only one word
PHP Code:
I need to kind of grep within grep. My input file would be something like:
[Code]....
and I need to find the first occurrence of hello before MY PATTERN (hello 9008 in this case), so the output should be:
[Code]....
I exported a spreadsheet file into cvs format.
The cvs file is formatted this way
field1,field2,field3,..etc
I want it to be in a Quote delimited format like so
"field1","field2","field3",..etc
How can I display the no. of lines, words and characters for each file in current directory and in sub directory.
wc . * shows errornous result as there are some executable files in that directory.
I am looking for this `struct messages_sdd_t` and I need to search through a lot of *.c files to find it.However, I can't seen to find a match as I want to exclude all the words 'struct' and 'messages_sdd_t'. As I want to search on this only 'struct messages_sdd_t' The reason for this is, as struct is used many times and I keep getting pages or search results.The directory I am searching in, has another directories so it will have to search recursively.I have been doing this without success:Code: find . -type f -name '*.c' | xargs grep 'struct messages_sdd_t'and thisCode: find . -type f -name '*.c' | xargs egrep -w 'struct|messages_sdd_t'
View 3 Replies View Related15 for(i = 0; i < N; i++) I want to replace "i" with "test" in the line above,whose line number is 15. When I tried this command :15s/i/test/ Line 15 turned to be this: for(test = 0; i < N; i++) It only replace the first "i",but I want to change all "i" in line 15.
View 3 Replies View RelatedI want to search lines with these stings with one or more spaces..
e.g
Code:
a b
a b
a b
a b
How will I achieve this by egrep ?
Quote:File1:
Hi, My name is John smith
Quote:
File2:
Hi, My name is smith
I want to show only the different or unique word between the two files (John)i was trying to get it with diff, comm, sort, uniq, grep, awk, sed
I'm trying to count words in a text file that has a comma as separator. I know that I must user wc -w, but wc uses space as a separator
View 2 Replies View RelatedI have some lines of text and I want to detect words that meet some criteria with sed.
E.g. The line "tetris cat dog test cactus stereotype"
I want to detect the word that contains two (2) ore more t letters. That mean the words tetris, test and stereotype.
The following regex doesn't do the job because it can;t distinguish words very well.
I thinks I have ti incorporate something like [^ ] in the regex but I wasn't successful...
i want to remove words "Max" and "constrained" in a file given below:
Max 0.003745 constrained
Max 0.004549 constrained
Max 0.001689 constrained
[code]....
and further want to replace "Max" by line number so that i can plot the resulting file. i searched in forum, but couldn't do what i wanted to do. e.g. i used
1)grep command
grep -v "Max" inputfile >outputfile
deletes whole line,and hence whole text.
2) sed command
cat inputfile |sed 's/ .{1,12} //g' >outputfile
gives output
0.003745constrained
0.004549constrained
0.001689constrained
[code]....
I have a folder with many many files. e.g html, docs, excel sheet, script etc.
Now I want to find {using grep command}a certain word in that folder/directory and delete it in all the files and scripts that have it.
For example, I want to delete the word /testing (with the slash) in all files in a directory.
I'm trying to use Sed to change all "l" letters with "I" in capitalized words something like this:
1. ONlON -> ONION
- and as opposite change the all "I" with "l" in a word in small letters such as:
2. DiIbert -> Dilbert
For the first case I'm using the below sentence which unfortunately changes words such as "let" in "It"
Code:
sed 's/[:upper:]*l[:upper:]*/I/g' test.srt
For the second case the below command seems to work but it might have a side effect as the one used in the first case:
Code:
sed 's/[:lower:]*I[:lower:]*/l/g' test.srt
I am looking for this struct messages_sdd_t and I need to search through a lot of *.c files to find it. However, I can't seen to find a match as I want to exclude all the words 'struct' and 'messages_sdd_t'. As I want to search on this only 'struct messages_sdd_t' The reason for this is, as struct is used many times and I keep getting pages or search results. I have been doing this without success:
find . -type f -name '*.c' | xargs grep 'struct messages_sdd_t'
and this
find . -type f -name '*.c' | xargs egrep -w 'struct|messages_sdd_t'
I have word like initialize_my_var:in sample.php and I included three library files, take it as a.php, b.php, c.php ,I really don't know where my label(initialize_my_var:)definition is present in my library files, is it possible with a pattern matching string to find which library file really have the exact term "initialize_my_var:" , I'm really looking for an exact pattern match.
View 1 Replies View Relatedi am experimenting with my squid config . but i dont know how to make this confg to work.I wanted to Block the websites on term of the "words''like if any one is accessing to Porn site then the words that come out of porn is blocked. [ mostly used examples]note:i can blocked single site at a time.second if there is user 10.10.10.21 is downloading MP3,AVi,mpg how can i not allowed him to download that both ways via right clicking download and direct download.
View 1 Replies View RelatedI want to find and remove duplicate consecutive words from a text file. I've tried working with array but is very difficult..then i've tried using sed...somebody hint me with this sed :
sed ':f;N;$!bf; s/(.*)
1/1
/g; s/(.*)1/1/g'.
It works fine but if i have 3 consecutive identical words it only remove first one and the last two remain intact.
I am basically trying to remove duplicate words in my <title></title> tag after I got hit by Google Panda. I have around 750 .html files and it will be difficult for to me remove one by one. I am looking for a way to remove only from within <title> </title>
Example of a duplicate title I have:
Code:
<title>Pasta, Pasta Recipe and Pasta Guide</title>
I dont want to replace those words anywhere else in the file except for within the <title>
I have a text file that gets produced at the end of the script being run.
For this example the text file will produce the following:
Quote:
THE COW
THE DOG
THE CAT
THE HORSE
In the script I am using either echo or printf to print on the screen each line and then it is doing a test and produces a good or bad result.
Another example:
Quote:
THE COW -- IS HOME
THE DOG -- IS HOME
Each whitespace between the -- are 5 spaces. How can I get them to be in-line and formatted when it gets to more words, when THE HORSE arrives.
Example:
Quote:
THE COW -- IS HOME
THE DOG -- IS HOME
THE CAT -- IS HOME
THE HORSE -- IS HOME <-- This has only 3 whitespaces but is still formatted.
I am having trouble keeping the name together and the phone number together, I think due to the white space. I have tried "" and '' it doesn't seem to matter. So it may be my syntax? and does it matter how long the first and last names are.
me$ echo 'fstname lstname' '123 123-1234' | ./myscript
#myscript
read a b
printf "%-15s %20s
" $a $b >> my_phone_numbers
OUTPUT
fstnamelstname
123123-1234
insted of
fstname lstname
123 123-1234
I know its not an elegant script but I am still learning how some commands work.
i am trying to find all 3 and 4-character length words in my file (which is huge and has alot of entries in it, a big fat wordlist!).My attempt with this regular expression (which I thought should work, found something on length search here: [URL]
cat sorted_noapostrophe.txt| grep '.{3,4}'
but it returns no results? Also to find any words starting with 'f' which are between 3 and 5 characters (inclusive) long, how can this be done?
I want to get list of all words from aspell dictionary.
I downloaded aspell and aspell polish dictionary, then unziped it using code...
It is connected to the declination and conjugation. How can I add to the first list all forms (with all corresponding suffixes as defined in .dat file ) ?
BTW: I need this list to spell-checker jazzy.
I need to find file from ls - l by using grep and certain regexp.
In particular I need greep to see certain file ending, like let's say .txt but only using regex.
So it should be something like
ls -l | grep '^.+.txt$'
But that doesn't seem to work for me.
Under a Linux shell, how can I change the creation time of all a folder's files to the current time?
View 2 Replies View RelatedI am trying to grep for A records in a bind zone file but I am failing.I am trying: grep "s+As+" db.domain.comBut there are no results.
View 12 Replies View Related