[SOLVED] Search in a file

Hi!
I'm working on a radio script with several functions, but i need your help to continue.  I want to search for a spefic string in a file. The files content is like:
Super Hot Girls Radio Channel;http://lovepotion.org:666
Sir Camelot Danish Radio;kingandnight.org:231
So if i search for "io", this will appear:
Super Hot Girls Radio Channel
Sir Camelot Danish Radio
Last edited by svanberg (2009-07-26 22:34:13)

Boris Bolgradov wrote:
brisbin33 wrote:
but, if in a script, and a variable is the search term you've got to switch the quoting like so
term="$1"
awk -F ';' "/$term/"'{print $1}' $file
You should also declare "file"
yeah, i figured that was implied.  i just meant to highlight the fact that something like $term wouldn't get evaluated if you used the single quotes as in the first literal-search example.  thanks go to procyon for showing me that trick.

Similar Messages

  • How to search a .csv file for data using its timestamp, then import to labview

    Hi, I'm currently obtaining density, viscosity and temperature data from an instrument, adding a timestamp and writing it to a .csv file which I can view in Excel. This works fine (see attached code) but what I need to do now is to search that csv file for data which was obtained at a certain time, import the temperature, density & viscosity values at this time back into Labview to do some calculations with them, while the data acquisition process is still ongoing.
    I've found various examples on how to import an entire csv file into labview, but none on how to extract data at a specific time. Also, whenever I try to do anything with the .csv file while my data acquistion VI is running, I receive error messages (presumably because I'm trying to write to and import data from the .csv file simultaneously). Is there some way around this, maybe using case structures?
    If you need to know my skill level, I've been using Labview for a few weeks and prior to that have basically no experience of writing code, so any help would be great. Thanks!
    Solved!
    Go to Solution.
    Attachments:
    Lemis VDC-30 read registers MODBUS v5.vi ‏56 KB

    It sounds as if you are going about this a little backwards writing to a data file and then extracting from the file but its the weekend so I can't think of an improved way to do it at the moment. 
    Searching for a specific time with those specific values is quite easy, or if you wanted to select any time then you could interpolate the values to find any value that you want (This is where the contiguous measurement comes in, as you have readings at discrete times you will have to interpolate the values if you want to get the 'measured value' at a time point that is not exactly one of your measured points).
    If you can extract the TDMS time column and the T, D & V then simply thresholding and interpolating each of your array/data sets should allow readings at your desired times.
    Attachments:
    Interpolate.png ‏301 KB

  • I backup to an external hdd with Time Machine, when it ran out of space it did not delete old backups, now my internal hdd says its full when before it had heaps of space. I have searched for extra files but cant find any. Can anyone help, please.

    I backup to an external hdd with Time Machine, when it ran out of space it did not delete old backups, now my internal hdd says its full when before it had heaps of space. I have searched for extra files but cant find any. Can anyone help, please.

    First, empty the Trash if you haven't already done so. Then reboot. That will temporarily free up some space.
    To locate large files, you can use Spotlight as described here. That method may not find large folders that contain a lot of small files.
    You can also use a tool such as OmniDiskSweeper (ODS) to explore your volume and find out what's taking up the space. You can delete files with it, but don't do that unless you're sure that you know what you're deleting and that all data is safely backed up. That means you have multiple backups, not just one.
    Proceed further only if the problem hasn't been solved.
    ODS can't see the whole filesystem when you run it just by double-clicking; it only sees files that you have permission to read. To see everything, you have to run it as root.
    Back up all data now.
    Install ODS in the Applications folder as usual.
    Triple-click the line of text below to select it, then copy the selected text to the Clipboard (command-C):sudo /Applications/OmniDiskSweeper.app/Contents/MacOS/OmniDiskSweeper
    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.
    Paste into the Terminal window (command-V). You'll be prompted for your login password, which won't be displayed when you type it. You may get a one-time warning not to screw up. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator.
    I don't recommend that you make a habit of doing this. Don't delete anything while running ODS as root. If something needs to be deleted, make sure you know what it is and how it got there, and then delete it by other, safer, means.
    When you're done with ODS, quit it and also quit Terminal.

  • Spotlight searches missing some files

    My searches in Spotlight are returning only some of the files that should be found. I finally narrowed this problem down to files that I had archived with BetterZip, but kept on my hard drive. The files are definitely still there on my hard drive, but they no longer appear in Spotlight searches. As soon as I open the files with an app, the files appear again in Spotlight searches. What has been done to the files that they don't appear in Spotlight searches? What is the fast method to change a setting/flag/unmark all the zipped files so they will all appear in Spotlight searches.
    Reindexing Spotlight has not helped--I have reindexed Spotlight probably a dozen times with various methods over the past few days and nothing happened until I opened and closed the file. Once I open the file, it's a matter of moments before it appears in a Spotlight search.
    System: OSX 10.4.11
    Thanks!

    I experimented some with rights and I can't see any consistent differences. All permissions seem to be 644 or 755. Neither the files that appear in Spotlight searches nor the files that do not appear in Spotlight are one or the other. Plus the permissions do not change after opening and closing the file.
    I am the Owner of all the files. I noticed that some files appearing in Spotlight had a different Group assigned, so I changed the Group on a few files, but that made no difference in whether the file appeared in Spotlight.
    Would upgrading to Leopard solve this problem?

  • I have 3 older ext. hard drives that I've utilized many times. Today while searching for old files, one of the three is no longer recognized by my PowerMac.  Any suggestions?

    I have 3 older ext. hard drives that I've utilized many times. Today while searching for old files, one of the three is no longer recognized by my PowerMac. The drive is not listed in Disk Utility.  Any suggestions?

    Is the computer in you equipment line:
    Dual Core Intel Xenon
    (which is not a PowerMac but a Mac Pro) the one you are asking about, or do you have an older PowerMac?
    If a Mac Pro, their forums are here:
    Mac Pro
    and, as Mac Pros have a totally different architecture from the pre-2005 Macs this forum covers, you may not have the same issues that can affect the older models. If someone didn't notice your equipment line, you could get advice that doesn't apply.
    If you really have a pre-2005 PowerMac, read on.
    If the stubborn external is USB and does not have its own power brick (i.e., it gets power only from the computer's UBS ports--"bus powered"), it may not be getting enough power. As electric motors age, they can demand more power than when new, and the power available on any USB port is limited.
    The typical workabouts to making a computer recognize an aging, bus-powered USB drive are:
    Get a powered USB hub (has its own power brick
    Get a "Y" USB cable: 1 Meter USB 2.0 A to 5 Pin Mini B Cable - Auxiliary USB "Y" Power Design for external hard drives.
    The second gets power from two USB ports on the computer and often that's enough.
    Remember that the USB ports on your keyboard seldom provide enough power even for a thumb drive, so be sure to use the USB ports on the back of the computer.

  • Using JScript to search an XML File

    I have an XML file that has three fields in each section like the following:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <CapabilityData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <capability>
            <oem>A.I.D</oem>
            <PartNumber>1426-5A-A1</PartNumber>
            <Nomenclature>AIRSPEED</Nomenclature>
        </capability>
        <capability>
            <oem>A.I.D</oem>
            <PartNumber>1426-5A-B1</PartNumber>
            <Nomenclature>AIRSPEED</Nomenclature>
        </capability>
    </CapabilityData>
    and what i want to do is search the xml file to find if a part number exists.  All this has to do is return a Yes or No response...
    The problem I am experiencing is that i can get the script to read the xml and display it on the screen but once i try to add in code to actually do a search it goes all haywire... i don't know if i'm jsut doing something stupid or if i'm doing it all incorrectly.
    Please be gentle, this is my first time...
    ~~~~
    <html>
    <body>
    <h1>OEM Search 2</h1>
    <button onclick="myTestFunction()">Try it</button>
    <script>
    function myTestFunction()
        var sPNSearchFor = "18B331";
        if (window.XMLHttpRequest)
          {// code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
        else
          {// code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        xmlhttp.open("GET","capability.xml",false);
        xmlhttp.send();
        xmlDoc=xmlhttp.responseXML;
        document.write("<table border='1'>");
        var x=xmlDoc.getElementsByTagName("capability");
        for (i=0;i<x.length;i++)
          document.write("<tr><td>");
          var sOEM=xmlDoc.getElementsByTagName("oem")[i].childNodes[0].nodeValue;
            document.write(sOEM);
            document.write("</td><td>");
          var sPN=xmlDoc.getElementsByTagName("PartNumber")[i].childNodes[0].nodeValue;
            document.write(sPN);
            document.write("</td><td>");
          var sNom=xmlDoc.getElementsByTagName("Nomenclature")[i].childNodes[0].nodeValue;
            document.write(sNom);
            document.write("</td><td>");
            document.write(sPNSearchFor);
            document.write("</td><td>");
        document.write("</table>");
    </script>
    </body>
    </html>

    Hi Tom,
    Please post your question in this forum, you could get more helpful answers there:
    ASP.NET Forums >
    General ASP.NET >
    HTML, CSS and JavaScript
    Thanks for your understanding.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Looking for a free iOS 4 app that can search through .pdf files or spreadsheets

    Looking for a free iOS 4 app that can search through .pdf files or spreadsheet    
    Thanks

    Hey there
    "pdf creator" for iPad works flawlessly for me working with pdf files
    It takes care of all my needs
    I'm not sure about sending via Wifi or Bluetooth but I send them via e- mail all the time
    Possibly it could handle your needs as well
    Just type it into the App Store search field and the first one that comes up is the one I use
    Jump on over there and read up on it before buying and see if it will help you 
    Hope this helps
    Regards

  • Urgent + Search a delimited file for more then one string

    Hi All
    Urgent please help I am trying to search a file for 2 different strings.
    This is how the command prompt will look like
    java match "-t|" -4 -f Harvey -10 -f Atlanta callbook.txtPlease help me with identifying how many search criterias have been entered on command prompt.
    "-t|" - denotes a delimiter
    -4 - denotes the field number
    -f - case sensitive
    Thanks

    Hi
    Thanks for your quick response and I apologise I will never put urgent on my posting again.
    C:\>java match "-t|" -4 -f Harvey -10 -f Atlanta callbook.txt
    This example lists records for Atlanta with first name Harvey.
    I am able to get one search criteria but when I have 2 as above (Harvey and Atlanta) I get lost I do not know how to get these arguments from the commandline and still do a search correctly. My code at the moment is doint a hard coded search so I was trying to extract the arguments that's where I got stuck.
    The main aim of my app is to search a delimited file for a search criteria passed through a command prompt.
    This is what I have done so far.
    import  java.io.*;
    import java.util.*;
    public class assess1
        static public void main(String args[])
            int[] totals = new int[10];
            try
                BufferedReader inFile = new BufferedReader(new FileReader(args[0]) );
                try
                    String line;
              String StrSearch = "HARVEY";
              int counter = 0;
                    boolean foundIt = false;
                    while((line = inFile.readLine()) != null)
                     // search for the string
                      String[] values = line.split("\\|");
                       for (String str : values) {
                   if (str.equals("HARVEY")) {
                               System.out.println(line);
                             System.out.println();
                        counter++;
              if (counter == 0) {
                   System.out.println("String not found");
              inFile.close();
                catch(IOException e)
                    System.err.println("IO exception");
                    System.exit(1);
                catch(NumberFormatException e)
                    System.err.println("Value " + e.getMessage() + "not numeric");
            catch(FileNotFoundException e)
                System.err.println( "Couldn't open " + e.getMessage() );
                System.exit(1);
    }

  • How Can I Search for Media files by Length?

    I want know how can I search for media files (mov, mp4, flv and movie files in general) by their length?
    If this search function is confirmed as definitely not possible on the OS, I would appreciate someone recommending app that might be able to perform such a search?
    Many thanks

    No possible way. Because the files may be enoded with differing codecs, compression, etc., you can only sort by file size, not the 'length' of the movie files.
    Clinton

  • How to search for a file and copy it to somewhere else in terminal

    So basically how can I search for a file on my computer named "testingtesting.txt" and copy it to my desktop using terminal? I have very little experience in terminal, so I was going to try and use the mdfind command, then store that output as a variable, and use that variable as the source for the cp command, but I feel like there is probably a much simpler method. So basically how could I find a file named "testingtesting.txt", copy it, and paste it to my desktop using terminal.

    Is there any particular reason that you must use Terminal?
    You could just download the free EasyFind from the App Store and find the file quickly. Do whatever you wish with it.
    Good luck,
    Clinton

  • Is there a function to Search a Text File?

    I am writing a program that will read data from a URL and then save that URL to a text file. I then need to be able to search the text file for certain strings and must know which line they appear on. I realize that I could read the text file in line by line looking for the string and then note the current line number. However, I need to search for 20-30 different strings in each URL and this would be very inefficient. I would really like some way to say:
    int lineNumber = 0;
    lineNumber = searchText("sometextfile.txt", str);
    And have searchText return the lineNumber on which the String str was found. Alternately, if there is way to search a URL that would cut out the middle man of writing it to a text file first.
    Any help would be greatly appreciated as I could not find this anywhere. Thanks.

    I have done something similar to to this, but it depends on what you want to use it for. I was looking for specific data on websites and would copy that data into a database. So, I used regex to find the data on the site and copy it. I also had to use String Tokenizer in certain places to get the correct data sometimes.
    orozcom

  • How to search for a file?

    Hi I am currently using the below code to detect a file automaticaly in a thumbdrive. So currently I have to state the path directory to detect the particular file. Is there a way to search for the file in the thumbdrive using Java?
    public class Detect {
    public static void main(String[] args)
    File f = new File("f:\\");
    while (! f.exists())
    try { Thread.sleep(500); }
    catch (InterruptedException e) {}
    System.out.println("drive inserted!");
    }

    You'll need to recursively search through a top directory and all its subdirectories for all files. Here is a link how to do this.
    http://www.javapractices.com/Topic68.cjp
    You can search for all drives A through Z for the file (using something like new File("F:") and catching the exception if not found (and dont do anything with the exception). But exclude C and D drive since they are usually hard drives and take forever to search through. Also, you may want to use File.separator instead of '/" or '\' in your code since windowsXP uses one while Unix uses the other and you would want your code to be able to run on either operating system.
    Are you building a web page with this? if so, it will not work since your search code would be running on the server and not on the client's machine. Even if you were able to run it on the client machine via his browser, you cant because of security reasons (end users dont want to give you access to thier drives). If its a web page, look into file upload html tag called <input type="file". This allows the end-user to navigate on his machine to where the file is and download it without you having to search for it.
    If you writing an application instead of a web page, I think there is an applet you can use that will do the same thing as <input type="file".
    Searching though a directory structure isn't good since it takes too long for users t wait.

  • How to SEARCH for specific file TYPES, e.g. PDF?

    If I know the title has in it "resume" and I know it's a PDF, how do you search for all PDF files that have the word "resume" in the title?
    AND..
    How would you search all PDF files that had the word "supervisor" inside the document?
    Thanks

    Command F should do it. Once the search window appears, you should see a drop down box headed kind and next to it one headed any. Select PDF from the any one. Click the plus button, and another field will appear and you can see again more drop down boxes. You just want to set these up so you end up with name and contains, you can then add your text to the remaining field.
    Also see [this|http://apps.tempel.org/FindAnyFile/index.html]
    Message was edited by: gumsie

  • How can i search for multiple file names (images) in bridge?

    Hello everyone!
    Does anyone know how to search for multiple file names in bridge?
    That is to copy & paste something like this: _MG_2152, _MG_2177, _MG_2194, _MG_2195, _MG_2202, _MG_2212, _MG_2219, _MG_2261, _MG_2362, _MG_2401
    Not using several criterias in the search box that is. That takes too long.
    Thanks
    Steffen Rikenberg Photographer
    Oslo, Norway.
    www.steffenrikenberg.no

    Try this add-on [https://addons.mozilla.org/it/firefox/addon/find-all/ Find All]

  • Problem searching some PDF files in Acrobat Reader – Non-ASCII characters

    Acrobat Reader cannot search some .pdf files.  I have put an example document up on Scribd here.
    Any attempt to search for any word that can be clearly seen to be in the document fails with “No matches were found.”
    This example document is NOT a scanned document – words and characters can be selected.
    A hex display tool shows that the characters in a PDF document that can be successfully searched are in the ASCII/1252 range (A=0x41, etc).
    Copying and pasting characters in the example document to a hex display tool shows that the characters in the document are not in the ASCII range.
    For example the letters A to Z in the example document are in the range ‘A’ = 0xDF (decimal 223), ‘B’ = 0xDE (decimal 222), through to ‘Z’ = 0xC6 (decimal 198).
    However, characters in these non-ASCII ranges are displayed perfectly by Acrobat Reader, as can be see if the example document is opened.
    Therefore, as Acrobat Reader knows what these characters are, it doesn’t seem unreasonable to say that it should be able to search for and find them.
    Tests were performed using Acrobat Reader X v10.1.4.
    Can anyone say what this problem is?

    Hi Pat, thanks for your reply. 
    Your reference to the title of that page being 'HARNESSES' indicates that, when you view that document in Adobe Reader, you are seeing 'HARNESSES', not
    "ØßÎÒÛÍÍÛÍ".  And that the remainder of the document is similarly being displayed in readable English language.
    Yes as you say, you can search for 'ß' and get hits on 'A' (to use that as an example) in the example document.
    But the need to form a word to be searched for into whatever code mapping this is using (for example having to enter "ØßÎÒÛÍÍ" for HARNESSES - I'm not even sure how that would be entered from a keyboard) doesn't seem to be very convenient.
    Its clear the example document is using some code mapping other than ASCII / Windows-1252 (which has 'A' as 0x41).  But it is also clear that Adobe Reader knows what that mapping is, and knows to use it, as its displaying (for example) 'A' for the code 0xDF. 
    So I guess the question is - why isn't Adobe Reader's knowledge of this mapping being extended to its search input? 

Maybe you are looking for

  • Please Help me to Choose the best config to run forms on web

    Hi, I have started upgrading my application from Dev2000 1.3 to Dev2000 6i in order to deploy on web. I have few questions to ask 1. I need to know which config is the best & fast to run my applications out of      1. Applet      2. IE50Native      3

  • Tool bar "pop-ups" won't pop. How do I fix this?

    I started having the problem in Adobe Fireworks CS5. I upgraded to CC and CS-6 Fireworks and I'm still having the same problems. I just tried Illustrator and Photoshsop and the toolbars there are broken as well.  All of my pop-ups are locked up. They

  • MM: Goods Movement

    Hi Gurus, We have highly complex SAP environment. I mean we have QM/WM with all functionality along with standard SAP modules and Handling Units. Now what happens when there is QI stock, it should not be transfered to unrestricted without Result Reco

  • Member Selection Button Fails in Excel

    Has anybody run into a situation where the Member Selection button does not work in Excel 2007? When someone tries to use the button Excel simply freezes forcing the users to re-boot the computer. This is happening on a handful of Corporate users mak

  • My iPad is not working with the Jensen

    My iPad is not working with the Jensen dock