grep

Help with grep in BBEdit

I'd like to grep the following in BBedit. Find: <dc:subject>Knowledge, Mashups, Politics, Reviews, Ratings, Ranking, Statistics</dc:subject> Replace with: <dc:subject>Knowledge</dc:subject> <dc:subject>Mashups</dc:subject> <dc:subject>Politics</dc:subject> <dc:subject>Reviews</dc:subject> <dc:subject>Ratings</dc:subject> <dc:subject...

line of bash code from .configure file

I need to understand the following line of code: BIN_DIR=`grep BIN_DIR= $SMLCM | head -1` where $SMLCH contains a path This is what I understood so far: grep will produce some string(s), possible paths. What does grep do with BIN_DIR=? the pathes are passed to head and all files within the paths will be used to extract their first ...

powershell basic syntax question for select

Background: Here the goal is to do some basic commands in powershell using select-string. For some reason, there are certain things that are not working as expected. Assume the following: $vfilter = 'c:/foo/bar/files/*.htm'; Select-String -path $vfilter -pattern ".*DOCTY.*" | sort LineNumber | where-object { $_...

get a part of a line after grep

I have a huge file on my unix server from which I need to extract certain parts The format of the line is aNumber timestamp commandInformation I use the command grep LATENCY file.log | grep CMDTYPE=NEW to filter out certain lines that I want. I only want the part timestamp and the last 9 characters from the line to be returned, n...

stdout to variable. with mktmp, sed, grep, etc. line by line

Hi, I use ldapsearch to get some users from my LDAP-Server. The command replies something like this: uid: name.surname homeDirectory: /home/name sambaSID: S-1-4-32-224545876-87201423761-4821562975-6853 sambaHomeDrive: G: description: poI description: pPI sn: naut givenName: givenName: peter mail: [email protected] Now I want to assi...

Exclude .svn directories from grep

When I grep my Subversion working copy directory, the results include a lot of files from the .svn directories. Is it possible to recursively grep a directory, but exclude all results from .svn directories? ...

Grep ignore multiple lines

Is there a way with Grep to use the -v switch to ignore a line and the next number of lines after it. Its basically to filter exceptions from a log file i.e. Valid log entry 1 Exception exceptionname at a.b.c at d.e.f ... Valid log entry 2 grep it to produce : Valid log entry 1 Valid log entry 2 I have tried grep -v Ex...

How to make grep stop at first match on a line?

Well, I have a file test.txt #test.txt odsdsdoddf112 test1_for_grep dad23392eeedJ test2 for grep Hello World test garbage I want to extract strings which have got a space after them. I used following expression and it worked grep -o [[:alnum:]]*.[[:blank:]] test.txt Its output is odsdsdoddf112 dad23392eeedJ test2 for H...

output filename, not string with select-string

I'm using powershell to "grep" my source code for a particular string. If the string is in the file, I would like the name of the file, not the line of code that contains the string. I would also like the name of the file, just once, not listed for as many times as the file exists. I'm currently using: gci . -include "*.sql" -recurse...

Why is this grep command not coming back with anything? (Bash)

I have a text file 'samp' that I want to grep ONLY lines that start and end with uppercase vowels. Using "grep ^[AEIOU] samp" works. Using "grep [AEIOU]$ samp" works as well. But when trying to combine them to "grep ^[AEIOU]$ samp" it returns nothing. 3 things: Yes, I have lines that start and end with uppercase vowels in samp. ...

How can I use grep to see if my word in a array has a match with list of word in dictionary and extract the exact single word?

Thanks for the answers... i am trying the different possibilities with all your answers. one thing: i could not be that much clearer in asking question to you all, ie. i m applying this RE in my local script/character(similar to Tibetan Script) and not in English word. foreach my $word (@list) { if(grep(/$word/, $dict)) # i have...

Trying to get rsync to copy files back to svn

I'm trying to setup a particular workflow but having trouble figuring out how(or if) rsync will work for this. My setup is on Mac OS X. I have my SVN directory. When I run my deploy script, the files are moved over to my integration Apache server. I perform my modifications to the files, then manually have been copying them back to SVN...

search with grep for words beginning and ending with

How to grep something which begins and end with a character ABC-0 ABC-1 ABC-10 ABC-20 I wanto to grep -v for ABC-0 and ABC-1 ...

How can I collapse this bash command line into an awk statement?

I've created an awk script and use it like this: # grep -E "[PM][IP][DO][:S]" file.txt | awk-script How can I modify the awk script to include the effort of the grep command (which is searching for either "PID:" or "MPOS"? awk-script is: #!/usr/bin/awk -f /Sleeve/ { printf("%8d, %7d, %7.2f, %7.2f, %7.2f\n", $5, $6, $7, $30,...

calling grep from a bash script

I'm new to bash scripts (and the *nix shell altogether) but I'm trying to write this script to make grepping a codebase easier. I have written this #!/bin/bash args=("$@"); for arg in args grep arg * */* */*/* */*/*/* */*/*/*/*; done when I try to run it, this is what happens: ~/Work/richmond $ ./f.sh "\$_REQUEST\['a'\]" ./f.sh: li...

grep egrep multiple-strings

Suppose I have several strings: str1 and str2 and str3. How to find lines that have all the strings? How to find lines that can have any of them? And how to find lines that have str1 and either of str2 and str3 [but not both?]? ...

Grep with "half"-exact match

Hi, I try to use grep to match a case like this: I have a list of hostname and ips in this format: 238-456 192.168.1.1 ak238-456 192.168.1.2 238-456a 192.168.1.3 458-862 192.168.1.4 Now i try to grep "238-456" but of course this returns: 238-456 192.168.1.1 and... ak238-456 192.168.1.2 and... 238-456a 192.168.1.1 but i only...

map string position to line number in regex output

I'm working on a "grep-like" utility in Python for searching Oracle source code files. Coding standards have changed over time, so trying to find something like "all deletes from table a.foo" could span multiple lines, or not, depending on the age of that piece of code: s = """-- multiline DDL statement DELETE a.foo f WHERE f.b...

Problem with regular expression using grep

I've got some textfiles that hold names, phone numbers and region codes. One combination per line. The syntax is always "Name Region_code number" With any number of spaces between the 3 variables. What I want to do is search for specific region codes, like 23 or 493, forexample. The problem is that these numbers might appear in the lon...

grep - search for "<?\n" at start of a file

I have a hunch that I should probably be using ack or egrep instead, but what should I use to basically look for <? at the start of a file? I'm trying to find all files that contain the php short open tag since I migrated a bunch of legacy scripts to a relatively new server with the latest php 5. I know the regex would probably be '/...