General :: Using Grep With Wildcards?
Jul 3, 2010
I searched and I found a few threads on this but none answered my question really.I'm using:
Code:
curl www.foo.com | grep '<h2>.*.</h2>'
Basically I want to extract all instances of
Code:
<h2>Blah blah blah</h2>
from the page source, but it's not giving me that, it gives me <h2>.. followed by a loads of other stuff that I don't want. I haven't used wildcards with grep before so I don't really know whether I'm doing it right or not.
View 5 Replies
ADVERTISEMENT
Feb 21, 2010
I'm trying to make a shell script, and for part of it I need to search through a file, find the ip in the file, and save ONLY the ip to another file. ( not the entire line that its on ) I understand grep has wildcards, where I could do something like, "grep (...........) traceroute-output for an ip address.
View 3 Replies
View Related
Jul 20, 2010
Is there a way to do a batch renames of files that will keep each individual filename, but change it in the way I want?
The specific issue is this. I have a harddrive with something like 1300 movies on it. They're all organized alphabetically, but there are like 200 movies that begin with 'The'. I want to rename all of these movies that begin with The so that the The at the beginning is dropped and added at the end (for example, turn "The Shawshank Redemption" into "Shawshank Redemption, The"). I'd like to do this with a simple command if its possible.
View 2 Replies
View Related
Aug 21, 2010
I'm try the use wildcards for file searches in Nautilus (ctrl+s) but using sets and character classes doesn't return any results. For example
[[:upper:]]*
[![:digit]]*
*[[:alpha:]]
[crm]*
Is this kind of notation supported in Ubuntu or do I have something wrong in my syntax.
View 1 Replies
View Related
Apr 18, 2011
I've got an interesting problem when it comes to wildcard entries in bind. If I put the following in:
qa.express IN A 172.16.0.10
* IN A 172.17.1.156
If I then look up "express.example.com" it doesn't return an answer - it *should* return 172.17.1.156, but it won't unless I put that hostname in specifically. qa.express.example.com resolves as expected.
View 3 Replies
View Related
Aug 1, 2010
I'm struggling with the Vim find/replace command using wildcards.
I have several, big html files with lots of instances of: <p stuffiwanttoremove>
I've been trying the Vim command: %s/<p *>/<p>/ge
but it doesn't seem to work.
Does anybody know what I'm doing wrong?
I realise there may be alternatives to this (eg a bash script)
View 2 Replies
View Related
Feb 7, 2011
I want to make a keyboard shortcut that runs the following command:
Code:
smplayer /tmp/Flash*
This is to play things as ..... videos etc. in smplayer using vdpau instead of the laggy flashplayer
The wildcard * works in terminals, but not in the command of the shortcut or in the Alt-F2 launcher... Could anyone point me to what I could write instead?
View 1 Replies
View Related
Nov 22, 2010
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]....
View 4 Replies
View Related
Sep 5, 2010
I am trying to clean up a collection of music files, often in windows i receive errors on the collection because some of the files have a "?" question mark in the file name, in windows this is not a valid character for file names. How can i search/find files with a question mark in the name? Each time i try to search for "?" i receive a list of items that match a wildcard search where ? is a wildcard. I want to find file names that actually contain the character "?".
View 2 Replies
View Related
Feb 27, 2010
I am cleaning up some text files to put on a website and am using the find/replace feature of Gedit extensively. The only problem I am having is that I can't find a way to use wildcards. For instance, I want to use the "?" and "*" in the same or similar way you do in bash. I already know that:
Represents a carriage return, and that is great, but I want to do something like: "?." to replace "A.", "B.", "1.", "2." with just plain spaces. The document in question is written in narrative, but has a bunch of outline markers in it, and I want to remove the outline markers.
I tried "escaping" the characters in a similar way as by using "?.", but that didn't work. Google was not very fruitful, and the Gedit help seems to be Gnome help and includes all kinds of useless info (for my problem) about wildcards in other programs.
View 2 Replies
View Related
Feb 15, 2010
having bit of a trouble with path expansion of strings that contain some whitespace and wildcards First my script sources a configuration file that contains array assignments
Code:
...
BACKUP_TARGET_FILES[2]=/boot/config-* # no problems
BACKUP_TARGET_FILES[3]="/root/random dir with space/file*" # this is the problem
...
then later in the script I want to expand BACKUP_TARGET_FILES elements as below
Code:
IFS_DEFAULT="$IFS"
shopt -s nullglob
shopt -s dotglob
IFS=
[code]....
this code seems to work but I'm not quite satisfied with it. I'd like to get rid those IFS changes, but haven't found out a solution as of yet. Problem with default IFS seems to be that with it neither $pattern or "$pattern" work; it either interprets pattern as multiple words (because of spaces) and so expands to wrong paths or it ignores * because it's within quotes.
View 11 Replies
View Related
Apr 7, 2011
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.
View 1 Replies
View Related
Dec 21, 2010
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 Related
Jul 15, 2010
I 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
Jul 29, 2010
Today, i checking my error log of Apache. I have look many IP brute scan URLo, i collect, export that to ip.txt and i need grep IP with connection >=8I don't know command to solve that. Example ip.txtQuote:
101 210.13.73.30
161 58.210.77.98
164 115.168.71.87
[code]....
View 2 Replies
View Related
Feb 3, 2010
I have a file which contains a line like this:SERVER=10.205.110.19 How can I cut out the IP and assign it to a variable?
View 4 Replies
View Related
Mar 28, 2010
How can I use grep expressions so that i can find strings like the ones bellow:
New York, NY
Virginia, VA
Oregon, OR
As you can see each city starts with capital letter then it follows up with a comma, and then with the Abbreviation of the city. I used :
Code: grep -w '[A-Z].*[a-z][,][' '][A-Z][A-Z]' filename But i get no results.
View 2 Replies
View Related
Feb 19, 2011
I have on my desktop around five java files. I also created a java file in directory Viti, located in desktop.
Since all java files contain string "class", I practice my usage of grep with the following:
And this works fine. However, when I type the following:
I expect to be shown the file that's located in my Viti directory, too, but it won't show it.
View 4 Replies
View Related
Dec 7, 2010
Let me *try* and explain what I'm trying to do, and keep in mind aside from a little command line stuff I'm a beginner to any of what I'm asking about.
I have a directory structure something like this:
Code:
/usr/local/chatlogs/
webserver1/
1.chatlog
2.chatlog
[Code]....
So that whatever was captured in the () in the first part of the statement would be used in the 1 in the back part of the statement for every n.chatlog that might be in any of the /webserver directories at that time.
View 2 Replies
View Related
May 13, 2010
any way we can change the delimiter that uses grep?
I think, by default, grep uses as the delimiter.
View 3 Replies
View Related
May 17, 2010
I forgot a lot of my command line. I am doing cat file | grep "error" and i would like it to show everything to the right of G:/ including G:/ if possible. I figure its an awk command but i dont know what. I tried awk '{print $8+}' but + does not work like i hoped and guessed.
View 2 Replies
View Related
Feb 22, 2011
When using the grep plugin to VIM, I can search the current directory for all occurrences of a string within a set of files, like this::grep Ryan *.txtThis outputs something like this:
file1.txt:3:Ryan was here
file2.txt:10:Ryan likes VIM
file3.txt:5:superuser.com is a fav of Ryan
[code]....
View 1 Replies
View Related
Apr 12, 2011
I'm wondering if it's POSIX + ASCII or something else is mixed in?
View 1 Replies
View Related
Mar 23, 2011
I have a server hosting 100+ websites. I need to quickly identify which websites are configured with a database. There are way too many to manually check every website for a PHP file with a database name. So, I created a list of all databases from MySQL and put them in a text file. I then exported the text file to a shell variable and used it in a for loop.
bash variable
Code:
DBLIST=`cat dblist.txt`
Example of $DBLIST
Code:
db1 db_testing2 database_clientname production words4cheap
for loop
Code:
for db in $DBLIST; do find . -type "f" -iname "*.php" -exec grep -i $db '{}' ; -print; done
Note: my find statement starts searching at . which is the directory that contains all of my websites and their data, each website is setup in a sub directory, identified by it's domain name.
Example: I'm in /var/www. Beneath /var/www are a list of directories:
[URL]
However, this is taking too long (it's been running most of the day) and I was wondering if there wasn't an easier way to accomplish what I'm trying to achieve?
View 4 Replies
View Related
Mar 9, 2011
I have a file like this:
Code:
I need to search it backwards for "notable line" strings AND the first numeric string preceding that line. I've discovered that it's easy to search backwards by tac file | grep pattern, but how to tell grep to continue searching from where the pattern was found? In short, I want to make the output of the example above into this:
Code:
Or I must use another tool, like awk or sed? If so, how do I do so?
View 3 Replies
View Related
Oct 15, 2010
I tried to run one grep that excludes symlinks and pipe it into a second that searches for my pattern but I continue to get the recursive directory loop error. As a result (I think) my grep is incomplete as the search just loops between directories symlinked together.
View 7 Replies
View Related
Dec 31, 2010
I have collection my routers configuration through rancid. Now i want to do the following,
Display all the files that contain the following words
C1841 AND HWIC-4ESW
I want to display all the files that contains both these words.
View 14 Replies
View Related
Feb 22, 2010
I am attempting to recover a deleted text file. I used dd to make an image of the sectors on the hard drive which contained the data. Now, since I am not getting good results with foremost, and know all of the lines I'm looking for contain "Style", I want to grep the .img, but when I do it runs out of memory. I have tried the grep option -D, set to skip, and tried adding a 3GB swap to account for the 2.7G image. It still "exhausts" it's memory, and it seems to happen really quick now.this is the output of ulimit -a
Code:
root: $ ulimit -a
core file size (blocks, -c) 0
[code]....
View 12 Replies
View Related
Sep 22, 2010
Is there any way i can pass two / three values to grep. Basically i want to list the lines in the file with three different values. Currently I'm using three grep to get my work done.
EG: more Filename | grep text1 | grep text2 | grep text3
BRs
View 2 Replies
View Related
Apr 16, 2010
I'm writing a program that works with text files, and I'm trying to create some filters with grep. I have various questions here, so I'll number them for clarity.
1) First of all, I'd like to know what wc -w is actually returning. The word count is less than what gedit is counting in Document Statistics, so obviously gedit is counting something (like newlines) that wc -w is not
2) Secondly, I was wondering if there was a way to grep x number of words. I'm looking for something like the -m option, but returning a certain number of words instead of lines. For example, to find the first 2000 words, do something like grep -someoption 2000 ".*" or using {1,2000}.
3) Finally, I'm trying to filter out headers and footers of a text file but having no luck. The text files are Project Gutenberg files, so they have standardized headers and footers. Here's an example: [URL]...
The header starts with "The Project Gutenberg EBook of" and ends with the line containing "START OF THIS PROJECT GUTENBERG EBOOK" The footers begin with: "End of the Project Gutenberg EBook of" My problem is, grep can find:
[Code]...
View 15 Replies
View Related