find

file search bash script

i am trying to make a very simple bash script to find files matching the given name in the directory structure of the current directory. So, I used the find function like this ARGS=1 E_BADARGS=65 E_NOFILE=66 if [ $# -ne "$ARGS" ] # Correct number of arguments not passed then echo "Usage: `basename $0` filename" exit $E_BADARGS fi...

CakePHP Multiple Conditions Not Working as Expected

I have a find() query with multiple conditions, but the returning array contains entries should be excluded by the conditions. I read in the CakePHP docs that the default operator is "AND", which should mean that the results have to meet every condition, right? Here is my code, in case something is wrong with that... $this->set('object...

bash: complex test in find command

I would like to do something like: find . -type f -exec test $(file --brief --mime-type '{}' ) == 'text/html' \; -print but I can't figure out the correct way to quote or escape the args to test, especially the '$(' ... ')' . ...

Find Help with multiple finds + multiple prunes

Hi! I need to come up with a find command that includes a few prunes as well as a find for multiple files. Here's what I need to come up with, in one command: ./virtfs -prune -o -type f -name error_log \( -path "./virtfs" -prune -o -path "./*/mail" \) -prune -o -type f -wholename '*/.trash/*' -path ./virtfs -prune -o -type f -ireg...

Restrict jqGrid columns eligible for searching?

Is there a way you can restrict which grid columns are eligible for searching on using the jqGrid search navigation bar feature? In other words, specify that only 3 of your 5 columns will appear in the field list on the Find bar. ...

How to find/fix files with MIXED line endings (0x0d 0x0d 0x0a)

I know I can "probably" fix them by using "flip -u" (cygwin flip) which basically removes one of the 0xd's leaving the file with DOS style line endings (0x0d 0x0a) (of course, technically speaking this might be considered a bug!). But the other side of it is that i'd like to do this selectively, ensuring that what I'm fixing really is a...

How to find missing values in a sequence with PHP?

Hi, Suppose you have an array "value => timestamp". The values are increasing with the time but they can be reset at any moment. For example : $array = array( 1 => 6000, 2 => 7000, 3 => 8000, 7 => 9000, 8 => 10000, 9 => 11000, 55 => 1000, 56 => 2000, 57 => 3000, 59 => 4000, 60 => 5000, ); I would like to retrieve all the missing val...

Find all files matching 'name' on linux system, and search with them for 'text'

Hi, I need to find all instances of 'filename.ext' on a linux system and see which ones contain the text 'lookingfor'. Is there a set of linux command line operations that would work? ...

Using -exec option with Find command in Bash.

I am trying to use the -exec option with the find command to find specific files in my massive panoramas directory and move them to a specified location. The command I am using below passes an error argument not found for -exec. Can somebody point out my error in parsing the command? Or would I have to create a pipe of some sorts instead...

How do you filter Ruby Find.find() results?

Find.find("d") {|path| puts path} I want to exclude certain type of files, say *.gif and directories PS: I can always add code inside my block to check for the file name and directory type, but I want 'find' itself to filter files for me ...

Using equal(),find() on a vector<complex <double> >

Hi all, This is a pretty straightforward thing, but I've been bashing my head trying to understand. I'm trying to compare the elements of a vector<complex <double> > vec with a complex <double> num to check if num already exists on vec. If it does, it is not added. I tried to use the equal() and algorithm, with no success. Does anybody ...

Escape whitespace when using backticks.

I've had a search around, and from my perspective using backticks is the only way I can solve this problem. I'm trying to call the mdls command from Perl for each file in a directory to find it's last accessed time. The issue I'm having is that in the file names I have from find I have unescaped spaces which bash obviously doesn't like. ...

How can I use File::Find in Perl?

I'm a bit confused from File::Find documentation... what is the equivalent to $ find my_dir -maxdepth 2 -name "*.txt"? ...

find largest power of two less than X number?

I m doing this def power_two(n, base = -1): result = 2 ** base if result < n: base += 1 power_two(n, base) else: if result == n: print base else: print base - 1 what is the pythonic way to find largest power of two less than X number? EDIT example: power_two(100) ret...

Ruby on Rails get records by highest price

Hey, I have a model Rails model called Orders that has a type_id, location, and price. Each type can have multiple orders at the same location with different prices. Check below for a idea of the table structure. id | type_id | location_id | price ----------------------------------- 1 | 1 | 1 | 12 2 | 1 | 1 ...

Add text at the end of document fragments on a Mac

On a Mac, I have a directory of html files that are all document fragments. Using the TexFinderX app, I was easily able to do a find/replace and add everything at the top of the documents that I wanted (i.e. etc.) . Now I need to find a way to add the closing tags to all of the documents (i.e. ). TexFinderX does not have a way to d...

How do I use the hash :condition on a .find for a nil? method in Rails (has_one relationship)

I want to find all Contacts where the value of their :has_one relationship to :contact_status does not have a value (does that mean nil?) I created an alias_attribute :status, :status_contact Can I do something along the lines of: contacts = Contact.find(:all, :conditions => {:contact_status => nil }, :include => {:status_contact} )...

Number of files in a directory

I'm try to find, in only one row, the number of files (*.rar) in a directory. For doing this I'm using the commands: for /f "delims=" %i in ('find /c ".rar" "D:\backup e ckpdb ept-icd\test\unload\lista_files_rar.txt"') do echo %i but the value of %i I have at the end is : D:\BACKUP E CKPDB EPT-ICD\TEST\UNLOAD\LISTA_FILES_RAR.TXT: 8...

How to find an distinct URL only in set A not in set B.

There are two sets of URL, both contains millions of URLs. Now, How can I get an URL from A that is not in B. What's The best methods? Note: you can use any technique, use any tools like database, mapreduce, hashcode, etc, . We should consider the memory efficient, time efficient. You have to consider that every set (A and B) have millio...

if a value from controller is nil, how do I display 0?

I am creating a report which looks for the number of emails sent during a period of time: I display it in the View as follows: <td><%= @emails_sent.size %></td> And it is generated in the Controller as follows: @sent_emails = ContactEmail.all(:conditions => ['date_sent >= ? and date_sent <= ?', @monday, @friday]) But sometimes ...