Search a string with in some file and get the name of file

i want to search a string in some files that are in a given directory and return the name of file having searched string.I am doing this with grep command as given below
import java.io.*;
public class linux_java {
public static void main(String[] args) {
try {
String command = "find . | xargs grep -l Resolv /data2/opt/jakarta-tomcat-4.1.24/webapps/Oa/BOG/*.txt";
final Process process = Runtime.getRuntime().exec(command);
OutputStream os= process.getOutputStream();
System.out.println("out put stream= " +os);
PrintStream stdIn = new PrintStream(new BufferedOutputStream(process.getOutputStream()), true);
System.out.println("Return code = " + stdIn);
} catch (Exception e) {
e.printStackTrace();
i dont know how to get the name of file that are return by the execution of command through process object. Please send the code for the same

thanks for your suggestion....
i change the code but now it is giving error as /usr/bin/find incomplete syntax....but i am giving the right syntax....
please confirm whether the syntax is correct...
import java.io.*;
import java.util.*;
public class linux_java {
public static void main(String[] args) {
try {
//String command = "ls -alt";
String command = "find /data2/opt/jakarta-tomcat-4.1.24/webapps/Oa/BOG -type f -exec grep -sl 'Aggarwal' {} \\; 2>/dev/null";
///grep -l System test/*java
System.out.println(" the command is"+command);
final Process process = Runtime.getRuntime().exec(command);
InputStream is = process.getErrorStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line="";
System.out.println(" the BufferedReader is"+br.readLine());
while ((line = br.readLine()) != null) {
System.out.println(" the files are"+line);
} catch (Exception e) {
e.printStackTrace();
}

Similar Messages

  • How can I open a file and get the data inside  file when using  WebStart

    When I use ClassLoader,
    Which methold can I use the read the information inside that file?
    Thanks
    Ryan

    Assuming you are trying to read the jar file.
    http://forum.java.sun.com/thread.jspa?forumID=22&threadID=572955
    rykk

  • I just wrote over firefox 3.6 with 5.0 for my mac OSX and discovered my mac won't support it. Is there a way I can recover all my lost files and get the old version back?

    i just wrote over firefox 3.6 with 5.0 for my mac OSX and discovered my mac won't support it. Is there a way I can recover all my lost files and get the old version back?

    You can download and install Firefox 3.6 from http://www.mozilla.com/firefox/all-older.html

  • Im switching email accounts on my itunes account am the computer isnt recognizing purchases made from my other account on the new one (apps). How can I sign in with my new account and get the purchases apps on both accounts?

    Im switching email accounts on my itunes account am the computer isnt recognizing purchases made from my other account on the new one (apps). How can I sign in with my new account and get the purchases apps on both accounts?

    This was EXACTLY what I needed about the purchases I made from my device. However, is there a way to re-download other ones you've made from a computer? Because I realized some of them were not just purchased from my device.
    This is a picture of what it looks like now:
    http://tinypic.com/r/107quxu/7
    As you can see, the stuff circled in red doesn't give me an option to download from Cloud Beta because it already says "downloaded".
    any way to get around that?

  • Is there a way to burn old cd's with new cd's and get the same volume/quality on playback?

    is there a way to burn old cd's with new cd's and get the same volume/quality on playback?

    RIP the CD as AIFF or WAV.
    Create a playlist then burn an audio CD.

  • To upload the ZIP file and get the filenames available in ZIP file in ABAP

    Hi Experts,
    For my requirement, file from legacy comes as ZIP file with number of files in that.
    Please provide one code sample to upload the ZIP file from local workstation and get the filenames available in ZIP file to check few filename validation checks for the available files in report program.
    Thanks in Advance,
    Regards,
    Basani

    1. Copy the ZIP file into App server
    2. Call function
      call function 'RFC_REMOTE_PIPE'
        destination 'SERVER_EXEC'
        exporting
          command = command  " Unzip command gunzip /path & file
          read = 'X'
        tables
          pipedata = std_lines
    then you can read the files and can validate the file names

  • How to read spool file and get the spool file number

    Hey everyone.
    I created a program ztemp that is calling another program ztemp2 within, ztemp2 creates a spool file. Now the requirement is I need to write a code within ztemp to download that spool request and then convert it to the pdf file. I know I can use program rstxpdft4 to convert the spool file to the PDF but for this I need to give the spool number, so can you please tell me how can I get the spool number and then fetch it to the program rstxpdft4 .
    Thank you.
    Rhul goel

    Hi,
       Please check the [link|Convert ABAP List to PDF and display without downloading first; (Rich's reply) and get the spool similarly.
    Or read from table TSP01 to get the latest spool using sy-uname.
    Regards,
    Srini.

  • File Name Copy (not text inside the file ) and change the extension of file

    Hi,
    I have a requirement in which I have to copy the file name (not the text inside file ) from one folder/dir to another folder/dir with some another extension.
    Suppose we have file abc.txt of 20kb in a folder ,we need this in another folder with abc.done extension of 0 kb.
    This I need just to trigger a process.
    I have a below code to copy some files from one folder to another but this code copies the complete file not the file name only.Need help.
    package com.sumit.collections;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.nio.channels.FileChannel;
    public class FileMove {
         * @param args
         * @throws IOException
         public static void main(String[] args) throws IOException {
              FileMove fm=new FileMove();
              fm.copyFiles();
         public void copyFiles() throws IOException { 
              File destination=new File("C://soft//test2");
              File srcDir = new File("C://soft//test");
         File[] files = srcDir.listFiles();
         FileChannel in = null;
         FileChannel out = null;
         for (File file : files) { 
         try { 
         in = new FileInputStream(file).getChannel();
         File outFile = new File(destination, file.getName());
         out = new FileOutputStream(outFile).getChannel();
         in.transferTo(0, in.size(), out);
         } finally { 
         if (in != null)
         in.close();
         if (out != null)
         out.close();
    Thanks
    Sumit

    Thanks for all your help.I got the solution.
    package com.sumit.collections;
    import java.io.File;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    public class DotDoneFile {
         public static void main(String[] args) throws IOException {
              DotDoneFile fm=new DotDoneFile();
              fm.copyFiles1();
         public void copyFiles1() throws IOException { 
              List<String> filnamne = new ArrayList();
              File destDir = new File("C://Barcklays-soft//test2");
              File srcDir = new File("C://Barcklays-soft//test");
              File[] listOfFiles = srcDir.listFiles();
         try{
         for (int i=0;i<listOfFiles.length;i++){
              if (listOfFiles.isFile())
              filnamne.add(listOfFiles[i].getName());
              System.out.println(listOfFiles[i].getName());
              File.createTempFile(listOfFiles[i].getName(), ".done", destDir);
         catch(IOException ioe)
         System.out.println("Exception creating temporary file : " + ioe);

  • I'm trying to download ML, and get the product distribution file error. I have repaired the permissions in Disk Utility, I don't seem to have a applestore cache. I am on a corporate network, so am thinking it might be firewall related. Ideas?

    Hello folks
    I've tried every option I can to self support, from disk repair to deleting caches (I don't usually use the appstore so don't have one), and I don't have a pckge file either.
    I'm on a corporate network that restricts access to iTunes, so suspect it may be related to a firewall issue, although it has been relaxed to let me access the app store.
    Any other ideas of what to check myself before I go to tech support, and what do I need to get them to do. They are not really a mac supporting unit, so I need specific instructions.
    I'm on a mac pro, upgrading from Snow Leopard, so download is my only option.
    Thanks

    Read this whole message before doing anything.
    Back up all data.
    Quit the App Store application if it’s running.
    Step 1
    Hold down the option key and select
    Go ▹ Library
    from the Finder menu bar. Delete the following items from the Library folder (some may not exist):
    Caches/com.apple.appstore
    Leave the Library folder open. Try the App Store again. If it works now, stop here. Close the Library folder.
    Step 2
    If you still have problems, quit again. Go back to the Finder and move the following item from the open Library folder to the Desktop:
    Cookies/com.apple.appstore.plist
    Preferences/com.apple.appstore.plist
    Test. If the App Store now works, delete the files you moved to the Desktop. Otherwise, quit again. Put back the files you moved, overwriting the newer ones that may have been created in their place, and continue.
    Step 3
    Launch the Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Triple-click anywhere in the line below to select it:
    test -d $TMPDIR../C/com.apple.appstore && rm -r $_
    Drag or copy and paste the selected line — do not type it — into the Terminal window. You should get a new line ending in a dollar sign ("$"). Quit Terminal.
    Test. If the issue is still not resolved, post again.

  • Can I unzip the .ipa file and edit the application.xml file

    I want to modify the below info to also have an additional string value of 2, which somewhere along the line tells something somewhere that the app can run on the ipad. Is there some info in the compiled application that will error out if I modify this document?
    <InfoAdditions>
    - <![CDATA[ <key>UIDeviceFamily</key><array><string>1</string></array> ]]>
    </InfoAdditions>
    into this
    <InfoAdditions>
    - <![CDATA[ <key>UIDeviceFamily</key><array><string>1</string><string>2</string></array> ]]>
    </InfoAdditions>

    you can change the file extension to zip, unzip it, find the application.xml file in one of the subdirectories, edit it, rezip the files, change the file extension to ipa and install.

  • Wind Vista SP2. iTunes 10.6.3.25. I'm trying to Consildate my Music Library on this PC, and get the error: "Copying files failed, because you don't have permission to change your iTunes Media folder or a folder within it."  My admin user has Full Control

    Any suggestions would be greatly appreciated!

    I did what you suggested on all three folders: The main Music folder on the Mac hard disk, on the iTunes folder on the external 160GB Hard drive which contains the current media content and on the new 2TB hard disk on which I created a new media folder. I selected permission for myself which were already read+write and chose the apply to enclosed items on all three folders. I then changed the permission for others to read+write and applied to enclose items also an all three folders.
    But it didn't solve anything.
    Here's what happens: I choose the new directory in iTunes preferences (the media folder on the 2TB disk) I then go to File > Library > Organize Library and then choose Consolidate files. A window pops up and says copying "filename" with a progression bar underneath but the filename never changes. Instead the beachball appears when the mouse pointer hoovers over iTunes. Upon pressing the iTunes icon in the Dock it says that iTunes is not responding. At this point there's 2 different ways:
    A - If I then force quit iTunes the iTunes window disappears but the application does not close. When I want to eject the 2TB disk it says it's being used by another application. Only when I cut the power to the 2TB disk does iTunes fully close. A window then pops up and says that the drive was not put away properly etc.
    B - if I cut the power to the drive without force quitting iTunes, a window appears with the said: "Copying failed because you don't have permissions to change iTunes media folders etc." iTunes remains open and fully functional.

  • Moving library to external hard drive and get the error "Copying files failed. The disk could not be read from or written to"

    Hello,
    I'm moving my library to an external hard drive.
    I've made sure to use the 'Keep iTunes Media Folder Organized' option when pointing to the new library location.
    I select 'File'->'Library'->'Organize Library', I select to 'Consolidate Files', click 'OK' and get ther error message "Copying files failed. The disk could not be read from or written to".
    I've read elsewhere that there may be a corrupted file that I need to sequester somehow and perhaps add it back however I'm not certain how I can locate that file because the status window doesn't indicate which file it's attempting to transfer when the error appears.
    Any tips?
    Thank you,
    Greg H
    iTunes 10.6.3

    OK I figured it out!
    It was a dodgy file....I sorted the file folders by date, and as it turned out within the "compilations" folder there was a CD where only about half the tracks seemed to have been copied over. Could not have identified this simply from the time indicated on the finder folder sort, because there were several CDs copied over in the that same minute.
    I went back to the original itunes folder, deleted all the files from that CD in itunes, then also deleted all those files from the original disk and the target disk.
    Tried the "consolidate library" again, and it completed nicely. 200megs of music and videos.
    Very happy to solve this problem after 3 weeks.

  • I have the following Imac and Iphoto 11 in Finder folder I upgrade the iphoto file  and  all the latest event files, can you help how to solve the problem? Thank you  Model Name iMac    Model Identifier:     iMa

    I have the following Imac and Iphoto 11 in Finder folder I upgrade the iphoto file  and I lost all the latest event files, can you help how to solve the problem? Thank you
    Model Name:     iMac
    Model Identifier:     iMac8,1   Processor Name:     Intel Core 2 Duo
    Processor Speed:     2.4 GHz

    http://support.apple.com/kb/HT2638?viewlocale=en_US&locale=en_US

  • I try to save a pdf as a tiff file and get the message the image is to wide to output?

    I am trying to save a map I have in PDF format as a Tiff file. When I "save as other - image -tiff I get the message:

    If it is a map, you likely already have a bit map. In that case use Export all Images to get the original bitmap back.

  • How to get the name of file was read from file adapter ?

    Hello!
    I make a pooling into one directory to read all *.fat files in this directory, and I want the name of this file
    is it possible ?
    God bless all!

    it is mentioned in the sample code.. look at the pdf guide inthe sample code document for file adapter.
    you need to define a variable of message type of the file adapter inbound header message type and assign the variable to the apapters tab in the receive activity..
    the variable will have file name now

Maybe you are looking for

  • How to handle entries in Oracle

    Hi expert, I am facing a functional issue, this is conceptual and I hope you guide my well. I am getting invoices from non oracle software into payables on daily basis. I have to pay against those invoices. suppose till today I receive 7 invoice with

  • Issues following SP2010 to SP2013 Upgrade - Password Prompt

    Hello, I have upgraded a SharePoint site from SP2010 to SP2013 and everything is working fine apart from the fact that whenever I create a new document I am prompted for username and password.  I can save the credentials but after rebooting the PC it

  • Adobe Air Deployment Questions

    I'm working on a commercial application.  This application gets sold to customers, then deployed by various customers on whatever server they would like.  It's a java backend flex front end.  That said, for the web-app, since the swf file is housed i

  • Memory could not be read - Robohelp 8.0.2

    When I open my project by double-clicking the project.xpj file, I get the following error, and Robohelp will not open: (Cancel appears to do nothing.) When I open Robohelp from the Windows Start menu, and navigate to the same file, it opens just fine

  • I owned a vintage MacBook late 2008.the problem is my network has jammed and showed no hardware install.what should I do?

    network icon showed no hardware install. Have checked the local dealer but they said the production of the hardware(air port card) has been discontinue and cannot be ordered from Apple. What should I do?macbook late 2008