I have a bunch of folders and subfolders. Each one contains, amongst other things, a text file called index.yml with useful data. I want to search through all of the different index.yml files to find instances of a search string. I must be able to see a few lines of context and the directory of the index.yml file that was found.
This...
$ cat weirdo
Lunch now?
$ cat weirdo | grep Lunch
$ vi weirdo
^@L^@u^@n^@c^@h^@ ^@n^@o^@w^@?^@
I have some files that contain text with some non-printing characters like ^@ which cause my greps to fail (as above).
How can I get my grep work? Is there some way that does not require altering the files?
...
The mysqladmin command returns the values in bytes. I will like to see the value in MB if it is greater than 1 MB (1048576 bytes).
$ mysqladmin variables
+---------------------------------+----------------------------------+
| Variable_name | Value |
+---------------------------------+-------...
Hi guys,
I have been trying to work out the syntax for this command:
grep ! error_log | find /home/foo/public_html/ -mmin -60
or
grep '[^error_log]' | find /home/baumerf/public_html/ -mmin -60
I need to see all files that have been modified except for those names error_log.
Reading about it here, but only one NOT regex there: ht...
I have a relatively large csv/text data file (33mb) that I need to do a global search and replace the delimiting character on. (The reason is that there doesn't seem to be a way to get SQLServer to escape/handle double quotes in the data during a table export, but that's another story...)
I successfully accomplished a Textmate search an...
I have a cshell script that is something like this:
`netstat -ap | & grep tcp | grep myprocess | awk '{print $4}' | awk 'BEGIN { FS = :"}{print $2}'`
This is how it works
1.
$ netstat -ap | & grep tcp | grep myprocess
tcp 0 0 *:1234 *:* LISTEN 8888/myprocess
2.
$ netstat -ap | & grep tcp | grep myprocess | ...
I've mastered the basics of Bash compound conditionals and have read a few different ways to check for file existence of a wildcard file, but this one is eluding me, so I figured I'd ask for help...
I need to:
1.) Check if some file matching a pattern exists
AND
2.) Check that text in a different file exists.
I know there's lots of way...
I work in a research group and we use the PBS queuing system. I'm no PBS master, but I wanted to script a search for if a job was running. To do this I first grab a string of all the jobs by using the results of a qstat call as my argument to qstat -f and then taking the detailed list of all jobs and searching it for the submitted file...
I have a sentence that I want to write a shell command to grep it from a text:
The sentence is:
self.timeout=2.0
However, as this is a part of code from a file.
so it this sentence could also be
self.timeout = 2.0
or
self.timeout =2.0
or
self.timeout = 8.0
that is: there may be blanks besides "=", and the value of self.timeou...
Can someone explain why this code doesn't work as expected?
I would expect it only to match the first character, and it does with literal characters, but the wildcard (.) and characters classes behave strangely:
I use -o just to demonstrate exactly how things are matching, it doesn't change what matches at all.
$ echo foo | grep -o '^....
I saved a value by shell command:
For example:
timeoutvalue=`echo "timeout=2.0"`
And I have to grep the value of timeout from another text, and replace it with this timeoutvalue.
For example, the text is egtest:
<host ip="255.255.255.0" name="testhost" description="hostfortest" connection="xmlrpc" timeout=4.0/>
I want to grep the v...
I have to extract a parameter from a configuration file, and replace its values with another given value.
The config file is:
<host ip="200.200.200.200" name="testhost" description="test server" type="TEST_Duplex " connection="xmlrpc" xmldefaulttimeout="2.0" xmlspecifictimeout ="8.0"/>
I have to replace the value of xmldefaulttimeout=...
I'm trying to get the size of the top level directories under the current directory (on Solaris). So I'm piping du to grep and want to match only those lines that have a single forward slash ie. the top level directories.
Something like:
du -h | grep -e <your answer here>
but nothing I try works. Help appreciated!
...
Possible Duplicate:
RegEx match open tags except XHTML self-contained tags
Excerpt From Input File
<TD class="clsTDLabelWeb" width="28%">Municipality: </TD>
<TD style="WIDTH: 394px" class="clsTDLabelSm" colSpan="5">
<span id="DInfo1_Municipality">JUPITER</span></TD>
My Regular Expression
(?<=<span id="DInfo1_Municipal...
hi
I have the file:
# more file
(WORD = (TCPIP = (PROTOCOL = TCP)(WORD = ALIAS_NAME)(PORT = 10234))
but when I try to match part of the line (by grep -w) in the file , grep also match the line (inspite this is part of the full line)
grep -w "(TCPIP = (PROTOCOL = TCP)(WORD = ALIAS_NAME)(PORT = 10234))" file
(WORD = (TCPIP = (P...
In Perl, how do I extract the text in a string if I knew the pre and post parts of the text?
Example:
Input: www.google.com/search?size=1&make=BMW&model=2000
I would like to extract the word 'BMW' which is always in between "&make=" and the next "&"
...
hi
I run the following on sun Solaris (its run OK on Linux) but not on sun Solaris
name="(WORD = (TCPIP = (PROTOCOL = TCP)(WORD = ALIAS_NAME)(PORT = 10234))"
echo $name | grep -o "(WORD = (TCPIP = (PROTOCOL = TCP)(WORD = ALIAS_NAME)(PORT = 10234))"
grep: illegal option -- o
Usage: grep -hblcnsviw pattern file . . .
my question which...
I am trying to use a file containing IP addresses as the basis for searching through a Cisco firewall configuration file. Normally, I would use something like:
for i in $(cat ip.file); do grep $i fw.config; done
But doing that returns absolutely nothing. If I put the above script into a file and execute it with the bash -xv flags, e...
if i want an alias to do "rgrep pattern *" to search all files from my current location down through any sub directories, what is an alias for rgrep I can add to my bashrc file?
i would also like it to ignore errors and only report positive hits
...
Hi I have lots of logfiles with ^[[1m (as vim displays it) in them. I want to watch a logfile life via
tail -n 1000 -f logfile.log | grep <expression-for-escape-sequence>
and only get lines that have bold in them.
I am not sure which grep options I should use and have tried the following already:
tail -n 1000 -f logfile.log | grep "...