find

How can I remove everything except listed files with the Find-command?

I have a list of hidden files in a file "list_files" that should not be removed in the current directory. How can remove everything except them with a Find-command? I tried, but it clearly does not work: find . -iname ".*" \! -iname 'list_files' ...

Union, Intersection and Exclude with the FIND-command?

I need to manage lists with find-command. Suppose the lists have random names in non-distinct lists (ie their intersection is not empty set). How can I do: A \ B find files in the list A except the files in the list B A intersection B find files common to the lists A and B Please, consult here. A union B find all files ...

How can I combine the Find-commands?

The question emerged my original question here. I try to find the common elements between the outputs of the two find-commands with a find-command. How can I get the command working? find `find ~/bin/FilesDvorak/.* -maxdepth 0` -and `find ~/.PAST_RC_files/.*` ...

How does the AND-operator work in the FIND-command?

My last question expanded, so let's analyse things separately. AND-operater, Intersection? I will give an example: $ find . | awk -F"/" '{ print $2 }' .zcompdump .zshrc .zshrc_copy .zshrc_somequy .bashrc .emacs $ find ~/bin/FilesDvorak/.* -maxdepth 0 | awk -F"/" '{ print $6 }' .bashrc .emacs .gdbinit .git .profile When I save the...

find -exec cmd {} + vs | xargs

Which one is more efficient over a very large set of files and should be used? find . -exec cmd {} + or find . | xargs cmd (Assume that there are no funny characters in the filenames) ...

How can I make a shell script using Perl?

I have a Perl script called replaceUp: #!/usr/bin/perl search=$1 replace=$2 find . -type f -exec perl -p -i -e "s/$search/$replace/g" {} \; The script does not get loaded. This suggests me that my script is wrong. How can you make a shell script using Perl? ...

Is it possible to look beyond self in self.posts.find?

Expanding on recent_posts_on_self below, I want to add an all_recent_posts_on_self method but I'm not sure if it's possible using the syntax self.posts.find. On the other hand, all_recent_posts_on_class seems straightforward. class User < ActiveRecord::Base has_many :posts, :class_name => "Post" , :foreign_key => "author_id" has_man...

After Rails console restart, parent model can't find associated child model objects (and then can)

I've been stuck trying to figure out why a counter cache on my (parent) BlogPosts table won't update from the (child) Comments table. At first I thought the answer provided in my earlier question might be the solution but something happened after I went to bed last night because when I woke up this morning and restarted my Rails console,...

Unable to have '0700'-protected programs startable at login in Zsh

I have the following code which should put programs startable in Bash. if [ "`uname`" = "Darwin" ]; then compctl -f -x 'p[2]' -s "`/bin/ls -d1 /Applications/*/*.app /Application:/*.app | sed 's|^.*/\([^/]*\)\.app.*|\\1|;s/ /\\\\ /g'`" -- open alias run='open -a' fi However, it does not work in my Zsh at all. I ...

Have Excel 2003 do a Find in a Word document and return the number of occurences

I have an Excel document that has a single column of strings (around 400 rows). I also have a Word document that may or may not have those strings in the Excel document. How can I have Excel do a Find in that Word document for each row in that single column and retrieve the number of times the given string appears? I only have Office 2...

Find text string using JQuery?

Say a web page has a string such as "I am a simple string" that I want to find. How would I go about this using JQuery? ...

bash: How to delimit strings to find files

What syntax should I use in a bash script to list files based on 3 dynamic values: - older than X days - in a specified directory - whose name contains a specified string? FILEAGE=7 FILEDIR='"/home/ecom/tmp"' FILESTRING='"search-results-*"' FILES_FOR_REMOVAL=$("/usr/bin/find "${FILEDIR}" -maxdepth 1 -type f -mtime +${FILEAGE} -name "${F...

Silverlight databinding to locate UIElements

Is it possible to locate UIelement(s) on the visual tree in silverlight by inspecting the databinding somehow for a business object being bound. What I want to do is locate elements using a lambda expression (or any other means) from the element being bound something like: var uielements = FindAllUIElements ( (businessObject)=> { busine...

How to sort a bunch of files alphabetically, recursively

On Ubuntu, I have a bunch of files in a tree all called 'output.txt'. For each file I want to sort the lines alphabetically with 'sort'. I considered find . -name output.txt -exec sort{} \; but this outputs the sorted lines to the console rather than updating the original files which is what I want. ...

cleaning up static html cache files - which is faster 'find -exec' or 'find | xargs'

In my web application I render pages using PHP script, and then generate static HTML files from them. The static HTML are served to the users to speed up performance. The HTML files become stale eventually, and need to be deleted. I am debating between two ways to write the eviction script. The first is using a single find command, lik...

Rails SQL Query with find

I want this SQL query to be written in rails controller using find select id,name from questions where id not in (select question_id from levels_questions where level_id=15) How will I do this?I am using Rails framework and MySQL db thanks in advance. ...

Unix 'find' + 'grep' syntax vs. awk

I was using this line to find the phrase, 'B206' within files in the directory I was in and all of its sub directories. find . -exec grep -s "B206" '{}' \; -print It crashes when it tries to read certain files and actually changes the title bar in putty to a bunch of weird characters For example, it crashes all the time when it hits ...

Is there some Unix util that will allow me to grep multiple files with little typing?

Right now I do this a lot: find * | grep py$ | xargs grep foo I recall there is some util that does this with way less typing, but which? UPDATE: I prefer to use the Bash shell if possible. ...

Suppress find & grep "cannot open" output

I was given this syntax by user phi find . | awk '!/((\.jpeg)|(\.jpg)|(\.png))$/ {print $0;}' | xargs grep "B206" I would like to suppress the output of grep: can't open..... and find: cannot open lines from the results.sample output to be ignored: grep: can't open ./cisc/.xdbhist find: cannot open ./cisc/.ssh ...

Shell script to extract particular content using find, xargs, and grep

Hi everyone. Well i am new to linux shell and i can't understand any regexp :( Here is my question: I have a directory called /var/visitors and under this directory, i have directories like a, b, c, d. In each of these directories, there is a file called list.xml and here is the content of list.xml belonging to /var/visitors/a directory...