find

How can I count the number of items using the FIND function in MATLAB?

How can I use the function FIND to count the number of items of a given value instead of using a loop? For example, in the array item below there are 3 occurrences of the number 23, 2 occurrences of the number 22, and 2 occurrences of the number 20. .... for i=2:n if item(i-1)~=item(i) nItem21(i)=1; else nItem21...

Pre-populating input in Java console

I'm making a console-based Java/Groovy application that does a lot of find/replaces in text files. If, say, the program knows you replaced foo with bar last time, it should by default know you probably want to replace the next foo with bar as well. My idea was to pre-populate the input field of the What would you like to rename this to? ...

std::map::find().

Hi, I have a simple struct which i'm using as a key in a std::map struct PpointKey{ unsigned int xp,yp; //pixel coordinates unsigned int side; PpointKey(unsigned xp,unsigned yp,unsigned side=5):xp(xp),yp(yp),side(side) {} bool operator==(const PpointKey& other) const{ const ...

how do i exclude more that one directory in this case ... find ./dir1 -name '.git' -prune

how do i exclude more that one directory in this case ... find ./dir1 -name '.git' -prune ...

Run command from variables in shell script

I wrote this piece of code to scan a directory for files newer than a reference file while excluding specific subdirectories. #!/bin/bash dateMarker="date.marker" fileDate=$(date +%Y%m%d) excludedDirs=('./foo/bar' './foo/baz' './bar/baz') excludedDirsNum=${#excludedDirs[@]} for (( i=0; i < $excludedDirsNum; i++)); do myExcludes=${...

remove all but last 5 directories with shell script and find command

-not sure if this belongs here or on serverfault- What I want to do it list all directories in a directory and delete all of them, except for the last 5. We have a deployment system in place that will incrementally do something link this: /var/www/html/build1 /var/www/html/build2 /var/www/html/build3 /var/www/html/build4 /var/www/html/...

Problem formatting a find with sed output

Hi I'm trying to clean a site from a js-trojan for a customer, it has added: <script src='http://nt02.co.in/3'&gt;&lt;/script&gt; to all html-pages. Since it's too many files to manually clean I tried to a do find like this: find ./ -type f -exec sed -e "s\<script src='http://nt02.co.in/3'&gt;&lt;/script&gt;\ \g" {} > {} \; Problem ...

Cakephp - Ordering containable

Hi, I am using containable to reduce the size of my finds but I have got stuck when trying to order the find data, the find can't seem to see the institution join. Here is my code - $result = $this->Candidate->find('all', array( 'conditions' => array('Candidate.id' => $candidatesCodes), 'contain' => array( 'History' => ...

find with -regex flag ti match files

hi all under /tmp directory I have the following files file1 file2 when I run the following find command with -regex , find command not match the files why? find /tmp -regex '/file(\d{1,3})/' ...

checking file size

I want to check the file size in shell script. I am trying to check if the file in a specific directory exceeded 2 gb i.e 2147483648 bytes. How can I easily do this in shell script? I have the following 2 files: -rw-rw-rw- 1 op general 1977591120 Jul 02 08:27 abc -rw-rw-rw- 1 op general 6263142976 Jul 01 18:39 x...

find command + to search direcories

hi all I used the following find command to search files find /tmp -regex ".*some_file" How I can to search on the same way directories? Yael ...

How to do Multi file find and replace from unix prompt

I want to replace 'localhost' with an actual ip like '1.1.1.1' in every file in a directory including subfolders, plus I want it to log the filenames it changed. I'm having a difficult time doing this, what command should I use? ...

Eclipse find in project?

Does Eclipse have a way to search a whole project for some text? Like Xcode's "find in project" feature. Thanks! ...

Rails -- Find with 3 conditions?

Hey, I got a find condition that is a bit lengthy and I'd like make it lengthier. SO far :conditions => ["name LIKE ? OR description LIKE ?", "%#{params[:search_keyword]}%", "%#{params[:search_keyword]}%"] Where it's searching the model for if the attribute :name or :description is like a param from a text box. Now I'd al...

Finding nr of an array value based on a string that exist in the array

Hi. I have an array for all the cars in a online game I'm making that look like this: $GLOBALS['car_park'] = array ( "Toyota iQ3", "Think City", "Lancia Ypsilon", "Smart fourtwo", "Chevrolet Matiz", "Mazda 2", "Peugeot 107", "Nissan Micra", "Mercedes-Benz 310" /* dårlige biler */ , "Lexus IS-F", "BMW M3 CSL",...

[PHP] - String lookup into unknown charset html content

Hi there guys, I'm using strpos to lookup for string into web page bodies. 50% it fails, although the search string is present. I have tried to strtolower both search string and searched content, same results. Probabily the problem arises when dealing with different charsets... Assuming: - search string charset is unknown - searched con...

How can you find the most recently modified folder in a directory using Ruby?

How can you find the most recently modified folder (NOT A FILE) in a directory using Ruby? ...

How do I filter or find a Model based on a method in that Model?

Hi, I have a controller which is looking for a set of Contacts from the Contacts table. Currently it looks like this: @contacts = @campaign.contacts.find(:all, :order => "date_entered ASC") The method in the contact.rb (Model) is this: def status return if statuses.empty? a= statuses.find(:last).status << ' (' << statuses.fin...

Rake db:populate - linking to *almost* random records with :offset

This is a simple issue but I have multiple cases in my populate file where I want to set order.link_id to any link where link.job_id = j.id. Order.populate 1 do |order| @links = Link.find_all_by_job_id(j.id) order.link_id = @links.find(:first, :offset => rand(@links.count)).id ... end This produces an error (2 arguments for ...

Linux command to find text in most recent file matching name pattern

I have a directory of files like so: parent /dir1 file1 file2 other something name_pattern.o23409284 name_pattern.o29203429 name_pattern.o39208235 /dir2 ... I want to run a command that will look in the newest name_pattern.o* file for a line beginning with: ***END ...