grep

Perl Arrays and grep

I think its more a charachters, anyway, I have a text file, consisted of something like that: COMPANY NAME City Addresss, Address number Email phone number and so on... (it repeats itself, but with different data...), lets assume thing text is now in $strting variable. I want to have an array (@row), for exa...

Find Usage/Declarations in a directory Netbeans 6.9 Javascript

How can I setup Netbeans to search all .js files in the same directory for declarations and/or usage? I am just getting my feet wet with Netbeans 6.9 for the first time. As far as I understand, one can't make a pure Javascript project ( http://stackoverflow.com/questions/2926379/pure-javascript-projects-in-netbeans ), thus I set up a du...

Shell script to find and replace a string

Hello I have a colleague of mine who is a procedural code developer and has same smtp server name sitting in 120 different files, now I have to change them to something else. But doing that one by one would be impossible. I am using "grep" to recursively search for a string in all the files sitting in that directory. But I am not sure if...

Bash script - Take system output and use it as a variable

Hi, Pretty simple question, I'm trying to get some output after executing a command and use it again. #!/bin/bash echo what's the source db name? read SOURCE echo what's the target db name? read TARGET db2 backup db $SOURCE online compress include logs READ SOME OF THIS LINE = SOURCE db2 restore database $SOURCE taken at $DB2TIME into ...

grep or sed or awk + match WORD

hi friend's I do the following in order to get all WORD in file but not in lines that start with "//" grep -v "//" file | grep WORD can I get some other elegant suggestion to find all WORD in file except lines that begin with // Remark: "//" not necessary exists in the first of the line it's could be some spaces after the first...

Finding a string pattern using grep

I'm trying to find a certain sequence in the text of several .txt files. I am looking for a string that is joined to a 4 digit number. e.g. Watson1990. I tested the regex using an online tester and it appeared to work, however the expression (or combinations of it) failed to produce an output on my files. My regular expression is as fol...

Splitting a binary file on binary delimiter?

I'm working on a shell script to convert MPO stereographic 3D images into standard JPEG images. A MPO file is just two JPEG images, concatenated together. As such, you can split out the JPEG files by finding the byte offset of the second JPEG's magic number header (0xFFD8FFE1). I've done this manually using hexdump/xxd, grep, head, and ...

Find files with no extension in linux and mass rename them

I have a bunch of files on my server that look like below. I need to write a script that will rename all the files from JPG to .jpg as you can see some of them already have the .jpg extension and some don't. Can you help me? I could do it in either bash or through php, whatever is easier, I just don't know how. Thanks Jason jects/Ed...

grep + problem with grep command

hi all I used the following syntax in order to find IP address under /etc (answered by Dennis Williamson in superuser site) but I get the message "grep: line too long" someone have idea how to ignore this message and why I get this? Lidia grep -Er '\<([0-9]{1,3}\.){3}[0-9]{1,3}\>' /etc/ grep: line too long ...

regex for finding Letter after Underscore

Hi I would like to write a regex using unix command that identifies all strings that do not confirm to the following format First Leter is UpperCase Followed by any number of letters Underscore Followed by UpperCase Letter Followed by any number of letters Underscore and so on ............. The number of underscores is variable ...

linux shell script to add leading zeros to file names

I have a folder with about 1700 files. They are all named like 1.txt or 1497.txt etc. I would like to rename all the files so that all the filenames are 4 digits long. IE 23.txt becomes 0023.txt. What is a shell script that will do this? Or a related question: How do I use grep to only match lines that contain \d.txt (IE 1 digit, t...

How to escape braces in grep

I want to grep for a function call 'init()' in all javascript files in a directory. How do I do this using grep? Particularly, how to escape braces (). ...

GrepCode: searching for String constants

I have been using http://www.grepcode.com/ a lot lately to dig into the internals of common libraries to determine what a specific error means. (like what does "Connection reset" mean when using Axis? turns out it means that the socket closed but the buffer doesn't contain an EOF marker in it... though i still can't replicate this except...

How do I find/search/grep an SVN repository history?

I need to search through all revisions of a Subversion repository to find file names and revision numbers that contain a particular string. I know that this will find occurrences in a dump: svnadmin dump $REPO_PATH | grep -i "Verdana" but the output is too cryptic. The output will include chunks of binary files that match. I have bee...

use php, grep and regex to search and replace lines of code in file

I have a php file that can read the contents of other files perfectly and return them as a string. $contents = $file->read(); // return as string. i need to be able to search and replace certain lines lines that begin with $this->Session->setFlash and end with , true)); must be replaced with lines that begin with $this->Session->s...

Regex (grep) for multi-line search needed

Hi all I'm running a grep to find any *.sql file that has the word select followed by the word customerName followed by the word from. This select statement can span many lines and can contain tabs and newlines. I've tried a few variations on the following: $ grep -liIr --include="*.sql" --exclude-dir="\.svn*" --regexp="select[a-zA-...

how to display all lines from one that match regex in linux.

I want to display all lines from one which match regular expression if I have a file foo bar123 baz12435 lorem ipsum dolor sit amet this display-from baz[0-9]* < file sould return (It doesn't matter if it display matched line or not) lorem ipsum dolor sit amet How can I do this in Linux (with sed, awk or grep) ...

How do I obtain only digits from a string?

Suppose I have a string like this: blah=-Xms512m I want the output as 512. I know I can get it using grep on Linux like this: echo $blah | grep -o -e [0-9]\\+ But this doesn't work on Solaris. Any nice solutions so that it's compatible on both, Linux and Solaris? Or atleast on Solaris? ...

filter with grep to print when text is NOT present in another file

I have a linux filter to extract all lines from an xcode project that contain localized strings and produce a sorted list of unique entries. The filter works fine and is shown below. grep NSLocalized *.m | perl -pe 's/.*NSLocalizedString\((.+?)\,.*/$1/' | sort | uniq The result is a list of strings looking like this @"string1" @"st...

grepping binary files and UTF16

Standard grep/pcregrep etc. can conveniently be used with binary files for ASCII or UTF8 data - is there a simple way to make them try UTF16 too (preferably simultaneously, but instead will do)? Data I'm trying to get is all ASCII anyway (references in libraries etc.), it just doesn't get found as sometimes there's 00 between any two ch...