How to ignore subdirectories in find command of unix

how to exclude subdirectories of a path from find command
/app
/app/fmbs
/app/fmbs/temp
find /app/fmbs -name *.fmb
i want to ignore any fmb file existing into subdirectories created under temp subdirectory.
regards

Not sure if this helps but instead of using "find" as you are giving a specific path why not use "ls"
Example:
# ls /app/fmbs | grep ".fmd" (This will list all file names in specified directory)
or
# ls /app/fmbs/*.fmd (This will list all file names & path in specified directory)
I hope this helps
I am working on increasing our list of useful 1 liner commands and what we've got can be found at unbreakablehelp.com main page left hand side there are two links.
Enjoy it.

Similar Messages

  • Help please! [using Runtime.exec() to run find command in UNIX]

    Hi guys! im trying to use exec() to run the UNIX find command
    that my application uses. As you can see from my sample code, the find command finds all files ending with html in my home directory. Unfortunately when I run the program it doesn't give me an output, but when I run it on the shell in the same directory as this code is saved, it works perfectly fine.
    Could someone please help me on this one. Many thanks! =)
    import java.io.*;
    import java.lang.String;
    public class RunCommand {
            public static void main(String[] args) {
                    try {
                            String[] command = {"find", "~/", "-name",
                                            "*.html", "-print"};
                            String find_str;
                            Process find_proc = Runtime.getRuntime().exec(
                                            command);
                            DataInputStream find_in = new DataInputStream(
                                            find_proc.getInputStream());
                            try {
                                    while ((find_str = find_in.readLine())
                                                                    != null) {
                                            System.out.println(find_str);
                            } catch (IOException e) {
                                    System.exit(0);
                    } catch (IOException e1) {
                            System.err.println(e1);
                            System.exit(1);
                    System.exit(0);
    }

    I don't see anythi obvious. In both catch blocks, call printSckTrace on the exception yhou caught.
    I think the real culprit is the ~ though.
    ~ is interpreted by some (most?) shells to men home dir. However, when you just exec a command, you don't have a shell to do that interpretation for you, so it's looking for a directory that's literally named ~.
    Either exec a shell (read the man pages for the shell of your choice, but for zsh I think it's "/bin/zsh -c find ~ blah blah blah) or else just put the actual path to your home directory into the string you pass to exec. You can get that from System.getProperty("user.home").

  • Runtime Environment + Linux + the "find" command

    Hi everybody,
    I want to write a small program which makes it easy for me to use the find command with Linux. I have experience with Java but I have never used the runtime environment before. I am not sure how to best execute the "find" command. I tried this:
        public static void main(String[] args)
            String command = "find -name \"*\"";
            execute(command);
        private static void execute(String p_command)
            // Show the executed command.
            System.out.println(p_command);
            // Get the runtime object and handle the command.
            Runtime rt = Runtime.getRuntime();
            try
                // Execute the command.
                Process proc = rt.exec(p_command);
                // Show the output of the command.
                InputStream stdin = proc.getInputStream();
                InputStreamReader isr = new InputStreamReader(stdin);
                BufferedReader br = new BufferedReader(isr);
                String line = null;
                System.out.println("<OUTPUT>");
                while ( (line = br.readLine()) != null) System.out.println(line);
                System.out.println("</OUTPUT>");
                // Show the exit value of the process.
                int exitVal = proc.waitFor();
                System.out.println("Process exitValue: " + exitVal);
            catch (Exception e)
                System.out.println("Could not excecute: " + p_command);
        }This piece of code returns this:
    find -name "*"
    <OUTPUT>
    </OUTPUT>
    Process exitValue: 0This is not correct, because it should return something like this:
    [jethro@laptop FindNix]$ find -name "*"
    ./nbproject
    ./nbproject/project.xml
    ./nbproject/project.properties
    ./nbproject/private
    ./nbproject/private/private.properties
    ./nbproject/build-impl.xml
    ./nbproject/genfiles.properties
    ./build.xml
    ./src
    ./src/findnix
    ./src/findnix/Main.java
    ./test
    ./manifest.mf
    ./build
    ./build/classes
    ./build/classes/findnix
    ./build/classes/findnix/Main.classDoes anybody know what I am doing wrong?
    Best regards,
    Jethro Borsje

    It looks like you doing all correctly. I don't know what does Runtime.exec() do with passed arguments, but if specify command in following way:
    String command = "find -name *";
    'find' executed through Runtime.exec() behaves as if it was executed from command line with arguments -name "*".

  • Why is the Find command in Notes always disabled?

    I would like to be able to locate text inside of notes in the Mac OS X version of Notes. The Find, Find Next, Find Previous, and Find Selected Text commands all exist in the Edit>Find sub-menu but they're always disabled. Is there something wrong with my installation of Mountain Lion or are these commands always disabled? How can I enable these Find commands in Notes?

    Entering text in the search sidebar filters the notes containing the text entered in the box, but it does not enable the Find commands nor highlight the text within the note. If you want to find the desired text within a very long note —and I'm sure we all have a few— you must copy the text into another application and use that application's Find command, make your changes, then paste the text back into the note.
    My question still stands. How can I enable the Find command which exists in Notes but which is always disabled? Is this simply a feature that was planned but never implemented? If the command was never intended to work in Notes, why was it included in the menu? Finally, since the Find command is standard in every other text editor, why would it not be included in Notes?
    As a Mac developer, I'm tempted to try and hack it into working, but I'd rather not have to.

  • I'd like cancel "Find my iphone" , because my phone stolen and found. How can I cancel the Erase command?

    How can I cancel the Erase command?

    Try logging into iCloud.com, & remove your phone from Find My Phone.

  • "Find " command andshell scripting

    hi,
    I recently tried to write a shell script that looks in a directory and deletes all files matching a certain pattern which are more than 45 days old.
    I used the "find" command. the problem is that the find command recursively searches all the subdirectories present. I NEED TO RESTRICT THIS AND ENSURE THAT THE SEARCH IS RESTRICTED TO THE SPECIFIED DIRECTORY ONLY.
    the script is as follows:
    for file in `find . -mtime +15 -print`
    do
    if [ -f $file ]
    then
    echo "Removing $file that existed more than 15 days."
    rm $file
    #use mv command to some temp dir for testing
    fi
    done.
    I am on a solaris 5.6 machine and need help that will work on that version. I tried other commands such as locate and glimpse but the ksh does not seem to recognze tham at all. Also there is man page entry for these commands.
    In solaris, the find command comes with an option called -depth that restricts the depth of the search but i am not able to work it. The man pages abt this option says:
    -depth : Always true; causes descent of the directory
    hierarchy to be done so that all entries in a
    directory are acted on before the directory
    itself. This can be useful when find is used
    does anyone know how to work this?
    Also, the man page mentions that the depth is determined by an environment variable PATH_MAX. I am not able toset this variable. The man page for that says:
    find will be able to descend to arbitrary depths in a file hierarchy and will not fail due to path length limitations (unless a path operand specified by the application exceeds PATH_MAX requirements).
    Can someone tell me how to restrict this?
    I would appreciate it if you could cc a copy to my mail id :[email protected] as i have a lot of trouble accessing the net
    Regards,
    Sailesh

    hi
    i got a way but why dont you break it in to two scripts first script will search for the file path and redirects in to a file and then when its search is end start the removing your file by grep the file path from that file i think its simple

  • How to ignore blank/null key figure value in BI Queries

    Reports on Multiprovider - we see some cells of a Key figure as blanks. These blanks are interpreted as zeros by the system and calculated accordingly resulting in incorrect values. As per our requirement, we need a count of all hard/real zeros only, not the blanks. For example, if there are 10 rows of which 6 are real zeros and 4 are blanks - our count should be 6 and not 10.
    How to ignore the blanks in BEx queries please?
    Thanks for your help.
    Upender

    Rakesh,
    It is not possible to find a pattern because the report is on a MultiProvider with 2 InfoProviders- Purchasing documents DSO and Material Movements InfoCube.
    Every Purchasing Document has several materials associated with it. These materials are compared with materials in Materials Movement. Not all materials in Purchasing Document are found in Materials Movement. For those Materials found in Materials Movement, the Quantity is obtained. For these found rows, the correct value is showing up - if the quantity is zero, it is showing in reports as zero. If the material is not found in Material Movements then Quantity shows up as blank values.
    My requirement is ignore such blank quantities and not count them. Only Quantities with 0 values should be counted. Currently both blanks and zero values are counted showing inflated count.
    Thanks,
    Upender

  • How can I run Runtime.exec command in Java To invoke several other javas?

    Dear Friends:
    I met a problem when I want to use a Java program to run other java processes by Runtime.exec command,
    How can I run Runtime.exec command in Java To invoke several other java processes??
    see code below,
    I want to use HelloHappyCall to call both HappyHoliday.java and HellowWorld.java,
    [1]. main program,
    package abc;
    import java.util.*;
    import java.io.*;
    class HelloHappyCall
         public static void main(String[] args){
              try
                   Runtime.getRuntime().exec("java  -version");
                   Runtime.getRuntime().exec("cmd /c java  HelloWorld "); // here start will create a new process..
                   System.out.println("Never mind abt the bach file execution...");
              catch(Exception ex)
                   System.out.println("Exception occured: " + ex);
    } [2]. sub 1 program
    package abc;
    import java.util.*;
    import java.io.*;
    class HelloWorld
         public static void main(String[] args){
         System.out.println("Hellow World");
    } [3]. Sub 2 program:
    package abc;
    import java.util.*;
    import java.io.*;
    class HappyHoliday
         public static void main(String[] args){
         System.out.println("Happy Holiday!!");
    } When I run, I got following:
    Never mind abt the bach file execution...
    I cannot see both Java version and Hellow World print, what is wrong??
    I use eclipse3.2
    Thanks a lot..

    sunnymanman wrote:
    Thanks,
    But How can I see both programs printout
    "Happy Holiday"
    and
    "Hello World"
    ??First of all, you're not even calling the Happy Holiday one. If you want it to do something, you have to invoke it.
    And by the way, in your comments, you mention that in one case, a new process is created. Actually, new processes are created each time you call Runtime.exec.
    Anyway, if you want the output from the processes, you read it using getInputStream from the Process class. In fact, you really should read that stream anyway (read that URL I sent you to find out why).
    If you want to print that output to the screen, then do so as you'd print anything to the screen.
    in notepad HelloWorld.java, I can see it is opened,
    but in Java, not.I have no idea what you're saying here. It's not relevant whether a source code file is opened in Notepad, when running a program.

  • Can i get access to the find command in Word via activeX?

    Does anyone know if it is possible to search through a word document using activeX commands from labview? Basically i need to use the "find" command from Word.
    Thanks for your help

    Excellent thanks a lot.
    I've now got the search function working but im having a little trouble getting the results i want. What do you mean by "new selection"? is this the output refnum from the execute node?
    Im looking to search through a word document for a certain paragraph number then highlight this paragraph in some way.
    At present i have used your method to find the section number and then used a frame property on the output refnum followed by select method cascaded from this. This has the effect of selecting the number causing the word window to jump to the desired point but only the first line of the paragraph is shown because it places the found text at the bottom of the screen.
    Do you have any suggestions as to how i could select the en
    tire paragraph? I also cannot get any output from the select method in this way, am i using it incorrectly?
    Thanks again for your time
    Alan

  • Using Find Command

    Help
    If anybody can try this and tell me how it works I would be forever grateful.
    I can not seem to get the FIND command to find timecodes
    of clips in a sequence. I have copied all my clips from my bin and pasted them into a new sequence I'll name search, then I use the find command to locate a specific TC. this yields no results everytime!
    It works for Names/Markers not for time code!
    I am using FCP 4.5.
    I really need this to work.
    Power Mac Dual 2.0 G5   Mac OS X (10.3.9)   FCP 4.5

    Thanks for the welcome & the reponses.
    The reason I am searching this way is because when
    you search in the bin it doesn't enter the colons
    for timecode like it does when you search a sequence.
    It does however at least WORK in the search bin mode!
    I wish it I could enter TC the same way as a sequence it is soo much faster
    If anybody has a inside track to Apples FCP code developers maybe they could put in the next upgrade.
    Power Mac Dual 2.0 G5   Mac OS X (10.3.9)  

  • Self-created invisible system file not found via Finder's Find command

    I need to see what is being created on my hard disk. To achieve that, I create a test file, call it .new in TextEdit, remove the hidden .rtf extension, and place it in one of the folders in /Library/Application Support. Then, I use Finders Find command, and ask to search This Mac, Created date: today, System files are included, File visibility Visible or Invisible, leaving the input field (for file contents or name) blank. The newly created file isn't found. I type its name into the input field, with the same result. I change its name to .new.plist . Same result. Suspecting that "System files" acutally means system files and doesn't include the Library on the top level, I place that same item in /System/Library/PodcastProducer. Same result.
    Seriously, this is entirely incomprehensible. The Find command obviously doesn't do what it says it does. Could anyone tell me how to get it to, or name some alternative?
    Thanks a lot.

    Actually you CAN get ressults for .whatever files and folders. I created a saved search for my home folder with the criterion of "File visibility::Invisible Items" and then "None of the following are true::Name contains" DS_Store, Icon or localized. The result is a list of 65 invisible items including things such as the files /Users/francine/Library/Preferences/ByHost/.GlobalPreferences.0017f20dca84.plis t (a dot file), /Users/francine/Library/Preferences/com.freeverse.5012 (something with the invisible flag set), the dot folder /Users/francine/.fontconfig, and many others of all of these types. I thought it was interesting that lots of them were inside the ~/Library folder, even though I did NOT specify including system files.
    I don't know why the original poster can't get Spotlight, using the the Command-f method, to display dot files. When I was setting my own invisible items search up I did manage to crash the Finder once, so it may be that the query for invisible items is buggy. Here's the Raw Query:
    (true) && (((kMDItemFSInvisible = 1) && (!((kMDItemDisplayName = "\DS_Store"cd) || (kMDItemDisplayName = "\Icon"cd) || (kMDItemDisplayName = "\localized"cd)))))
    If you go to a folder, do Command-f, then change from the default "Kind" to "Raw Query" and paste the above in as the query, you ought to get all the invisible files and folders, except the .DS_Store, Icon and localized files (of which there are likely hundreds of 'em in your home folder).
    Francine
    Francine
    Schwieder

  • My MacBook Pro os 10.6.8 find command doesnt work

    My MacBook Pro os 10.6.8 find command doesnt work.  Someone mentioned indexing the hard drive but I dont know how.  Any help would be appreciated

    Importing photos and videos to computer
    http://support.apple.com/kb/ht4083

  • Find command doesn't find embedded string, only initial string

    iMac 5K, Yosemite
    In Safari and Preview, I note a change from earlier versions. When I use the cmd-F Find command to search the contents of a page or document, it finds only cases where the search string is at the beginning of a word, not when it is in the middle. This can be really a problem for some kinds of searches, for example when you know the root word but can't anticipate all of the prefixes that could be used in the document.
    Silly example: search for "fringe" does not find the word "infringement".
    This is really disconcerting, especially as it marks a big invisible change over how string searching has worked since time immemorial (try searching for "memorial". Hah.)
    I don't see any preference that would let me specify what kind of searching I want to do. There needs to be at least a preference. Or a big warning that says, oh by the way, just because you didn't find it, doesn't mean it isn't there.

    Did you read my hint at http://www.macosxhints.com/article.php?story=20080229204517495 ?

  • File path from find command and using POSIX

    Hi,
    I have a find command in do shell script returning output files of the form ./xyz/abc/.../...
    instead of the full path.
    I am guessing that this is the problem when I use POSIX path of one of those files. Can Applescript understand the "./" or does it need a full Unix path to convert it back?
    In that case, how do I ask find command to return the full path?
    Thanks in advance!

    >I am guessing that this is the problem when I use POSIX path of one of those files. Can Applescript understand the "./" or does it need a full Unix path to convert it back?
    You're right - AppleScript won't be able to use those paths because AppleScript has no idea of the current directory used by the shell.
    The problem is that you're defining '.' a the start point of your search.
    For each matching file find will print this start point in front of the relative path, assuming that you know where you're starting from. So the solution is to provide that path as the search start point rather than .
    For example, if your current script says:
    <pre class=command>cd /some/directory
    find . -name "*.mp3"</pre>
    You could/should rewrite this as:
    <pre class=command>find /some/directory -name "*.mp3"</pre>
    in the second case all matches would include the full path including the /some/directory part.
    If you can't predict what your search directory will be you can write your find like this:
    <pre class=command>find `pwd` -name "*.mp3"</pre>
    which will fill in the current directory (via pwd at the time the search is executed and will output full paths that AppleScript can work with.

  • How to Ignore  the signal?

    Insert a number if the number of digits of that number is greater than its average return true else false.
    So what i'd like to know , (and btw sorry about the other questions) how can it ignore the signal ?
    e.g: number_aux = 53 -> this will be: Number of digits: 2
    Media = (5 +3) / 2 = 4
    ( 2 < 4 ) then return false. now i'd like to find a way to insert -53 (negative) and the output must be the same (false) ignoring de signal "-"
    here is my code:
    In this code if u inserted a negative ( -6 or -53) the output is always true because e takes in mind the signal . How do i tell him to ignore it?
        System.out.println.... 
          int number _aux =Integer.parseInt(... ....etc
                                              int sum = 0;
              int count = 0;
              int media;
              while (number_aux != 0){
              int digit = number_aux % 10;
              number_aux  /= 10;
              sum += digit;
              if(number_aux  >= 0) count++;
              media =(int) (sum / count);
              return (count > media);thank you so much.
    Josh

    I already used my brain LOLO , if new the answer i
    would not be here ask for help lol.
    shiver You forgot to add three or more exclamation marks.
    give me a hint , how to ignore the signal without
    that method ( using my code)If I'd give you any number, how would you do it? What would there conditions and formula be? Think about that. Programming isn't magic. It's finding a step-wise solution to a problem and writing it down.

Maybe you are looking for