Hello, everyone.
I am trying to create a script, and one part requires showing lines with numeric values.
My basic syntax is:
echo $i | grep [0-9]
For example, I set i=12345, it should output 12345.
But on one server, it doesn't output anything (exactly the same commands).
I do not know how to Google this issue, I have tried "grep...
i need to make a graph with numeric values in a time period, the values represent online users in a web page.
the script will be exectued with cron every 30 mins and the needed html file will be downloaded with wget. but there are some yet unanswered questions & problems:
-i need to get just the numeric value from html code (but grep r...
I need some way to find words that contain any combination of characters and digits but exactly 4 digits only.
EXAMPLE:
a1a1a1a1 //OK
1234 // Not
a1a1a1a1a1 Not
...
i'd like to implement the unix command 'grep -r' in a python function. i know about commands.getstatusoutput(), but for now i don't want to use that. i came up with this:
def grep_r (str, dir):
files = [ o[0]+"/"+f for o in os.walk(dir) for f in o[2] if os.path.isfile(o[0]+"/"+f) ]
return [ l for f in files for l in open(f) if...
Hi,
Does anybody know how to code a regular expression (for use with some grep like tool) which will search for the word 'vat' but exclude the word 'pri**vat**e'. I've taken over a project which has hundreds of references to VAT (some hard-coded, some not) and as the VAT rate in the UK is changing on January 1 I need to update the proj...
I'm looking for a way to bail out of a makefile if a certain string is not found when checking the version of a tool.
The grep expression I'm looking to match is:
dplus -VV | grep 'build date and time: Nov 1 2009 19:31:28'
which returns a matching line if the proper version of dplus is installed.
How do I work a conditional into my...
I've got this little script in sh (Mac OSX 10.6) to look through an array of files. Google has stopped being helpful at this point:
files="*.jpg"
for f in $files
do
echo $f | grep -oEi '[0-9]+_([a-z]+)_[0-9a-z]*'
name=$?
echo $name
done
So far (obviously, to you shell gurus) $name merely holds 0, 1 or 2...
Is there any way I could use grep to ignore some files when searching something, something equivalent to svnignore or gitignore? I usually use something like this when searching source code.
grep -r something * | grep -v ignore_file1 | grep -v ignore_file2
Even if I could set up an alias to grep to ignore these files would be good.
...
is there a way to search and replace a string using single unix command grep recusrsively in multiple directories?
i know it can be done by using the combination of find with other utilities like sed perl etc.but is there a way where we can use only grep for doing this on unix command line?
...
I need a way of searching a file using grep via a regular expression 'RE' from the unix command line. For example when i type in the command line:
python pythonfile.py 'RE'
'file-to-be-searched'
I need the regualr expression 'RE' to be searched in the file and print out the lines that contain the RE.
Ok so heres the coding i hav...
My shell has a call to 'fortune' in my .login file, to provide me with a little message of the day. However, some of the fortunes begin with one leading whitespace line, some begin with two, and some don't have any leading whitespace lines at all. This bugs me.
I sat down to wrapper fortune with my own shell script, which would remove a...
Hello, I am trying to create regex dynamicly and then run it, this is part of script
...
param="egrep $2 $1"
shift
shift
while [ $# -ne 0 ]
do
param="$param""|egrep $1"
shift
done
$param // here i get error
...
but echo for $param seems to me ok
.P F1 a b c // run script
egrep a F1|egrep b|egrep c
Wha should i do in order to run $param...
I want a sed script that I can use for 1) finding instances, and 2) printing this string:
<bean:write name='iframesrcUrl'/>
<bean:write name="iframesrcUrl"/>
<bean:write name="currentPage" property="title" filter="false"/>
or similar. name and property values can differ. property and filter attributes are optional. Both single quotes...
I am trying to understand why grep built by me is much slower than the one that comes with the system and trying to find what compiler options are used by grep that comes with the system.
OS Version: CentOS release 5.3 (Final)
grep on system:
Version: grep (GNU grep) 2.5.1
Size: 88896 bytes
ldd output:
libpcre.so.0 => /lib64/...
I was using the return value of fgrep -s 'text' /folder/*.txt to find if 'text' is in any .txt file in /folder/. It works, but I find it too slow for what I need, like if it searches for 'text' in all the files before giving me an answer.
I need something that quickly gives me a yes/no answer when it finds at least one file with the 't...
how do i recursively grep all directories and subdirectories ?
find . | xargs grep "texthere" *
...
I'd like to use grep to find out if/where an html class is used across a bunch of files. The regex pattern should find not only <p class="foo"> but also <p class="foo bar foo-bar">.
So far I'm able to find class="foo" with this example below, can't make it work with multiple classnames:
grep -Ern "class=\"result+(\"| )" *
Any sugges...
Hi,
I know how to search for a string in files using grep
grep -Flr --include "*" 'string' files/
However how would I search for right double angle quotes ( » ) as the character will not appear in the terminal.
Thanks.
...
I have a 200 Mb text file and for every line need to swap the 3rd and 4th characters with the 6th and 7th characters, so that
1234567890
would become
1267534890
I am using Windows XP with PowerShell installed. Also installed is Cygwin and UnxUtils so have access to versions of cut, sed, awk, grep, etc. There is no delimiter in the fi...
I want to run ack or grep on html files that often have very long lines. I don't want to see very long lines that wrap repeatedly. But I do want to see just that portion of a long line that surrounds a string that matches the regular expression. How can I get this using any combination of unix tools?
...