New answers tagged

2

Create a function: mygrep() { find /path -type f -exec grep -irl "$1" {} +; } mygrep waldo Actually, why do you even need find? mygrep() { grep -irl "$1" /path; }


0

Only thing i can think of right now, for this particular case is to create a SEARCH_PATTERN environment variable and chance it each time you want to use it. Quick example; $ SEARCH_PAT="abc" $ find /path -type f -exec grep -irl "${SEARCH_PAT}" {} \; $ SEARCH_PAT="xyz" $ find /path -type f -exec grep -irl "${SEARCH_PAT}" {} \; etc...


1

sed, awk, others, many could do this. tr one: tr -d '"' < file The -d option is to delete things. And tr doesn't just read files, so use < to feed file content to it. It's same as: cat file | tr -d '"'


0

-o (only print the matching part of the line) is the same on both BSD and GNU grep. -P (use Perl-Compatible Regular Expressions, a.k.a. "PCRE") is specific to GNU grep. Luckily, your example regular expression doesn't use any PCRE-specific syntax. But it doesn't conform to classic Unix RE syntax either. It needs "Extended" Regular Expressions (EREs). You ...


0

You can safely forget about for for looping over filenames with spaces. Not necessarily... IFS=$'\n' && for NAV in `ps aux | egrep -o 'Google Chrome' | sort | uniq`; do open -a "$NAV" http://www.google.com done


0

You can do this with the help of awk and grep. Try this code: awk '/01:50:48/, /01:56:48/' <<FILENAME>> | grep 'Successful login. Username: XYZ,\s\+xxxxx' Where /01:50:00/ is the start time and /01:56:00/ the stop time. Replace << FILENAME>> with the path to your log file.


0

I would suggest a regex expression, perhaps something like this: /<[^>]*>/g The expression should exclude the tags you mentioned as well as things such as etc.


0

Example: open a bash call the command exec > >(cat | cat >>/tmp/myoutput.txt) call another command eg. `ls -R /usr' end bash with exit have a look into file /tmp/myoutput.txt, you will see the output of the lscommand if you exchange the command from step with this exec > >(sed 's/usr/--HEREAMI--/g' >/tmp/myoutput2.txt) This is ...


0

The external executable for :grep is controlled by the 'grepprg' option, and on Windows, this defaults to findstr, as :help 'grepprg' details: For Win32, the default is "findstr /n" if "findstr.exe" can be found, otherwise it's "grep -n". So, just put the following into your ~/.vimrc: set grepprg=grep\ -nH


1

You need use RegEx that find lines containing certain words: Matches a complete line of text that contains any of the words "one", "two" or "three": greedy: ^.*\b(one|two|three)\b.*$ lazy: ^.*?\b(one|two|three)\b.*$ Matches a complete line of text that contains all of the words "one", "two" and "three": ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$


1

Use the switch -i with grep to specify case insensitive.


0

The issue is that you are not adding the filenames to the open command, rather you are feeding the output of the grep into the open command. There are a few ways to do this, including open navigation-drawer-config-* Which will use GLOB expansion and is probably the fastest and simplest approach. Or open ls | grep "navigation-drawer-config-" ...



Top 50 recent answers are included