Search file for text and delete the found text.  How?

I need to know how to search a file for text and delete the found text. I think grep will let you do this but not sure of the syntax.

Hi Dmcrory,
   In addition to what Camelot and nobody loopback point out, one must also consider the fact that UNIX text tools are largely line based. You also fail to tell us for what kind of text you are searching. If you are looking for multiple words, there's a very good chance of finding the expression wrapped onto different lines. With hyphenation, even single words can wrap to multiple lines. Tools that search line-by-line will miss these unless you use multiline techniques.
   Multiline substitutions require that you write "read-ahead" code for the command line tool that you're using and that you take that into account in the substitution. Given how you want the results to be printed out, you may also want to preserve any newlines found in the match, which is even more difficult. That could bring up the subject of line endings but that's a completely different topic.
   I apologize if this sounds discouraging. Multiline searches aren't needed that often and in most of those cases, exceptions can be dealt with by hand. I just didn't want you to get surprised by it. To give you an idea of how easy basic substitution is, have a look at Tom Christiansen's Cultured Perl: One-liners 102 and One-liners 101. Both have some "in-place" substitution examples.
Gary
~~~~
   MIT:
      The Georgia Tech of the North

Similar Messages

  • I created a 2nd itunes account, not I want to merge the 2 accts and delete the old one - how do i do this?

    i created a 2nd itunes account, not I want to merge the 2 accts and delete the old one - how do i do this?

    Any reason you created a new account instead of updating the old account with any new info?
    You cannot merge accounts. Anything purchased on an account will stay linked to that account and cannot be changed.

  • Searching paragraphs using automator and deleting the search results from the original body of text

    How do I search paragraphs of a text document using automator and then have the search results deleted from the text document after those search results are exported to a textedit document?

    How do I search paragraphs of a text document using automator and then have the search results deleted from the text document after those search results are exported to a textedit document?

  • Creating search help for AFNAM, and display the hit list with values only

    Hi guys,
    I have created a search help for AFNAM, but the hit list displays all even if it is blank.
    I want to display in the hit list the AFNAM with values and do not diplay the blank values...
    Is it possible? How am i going to do it?
    Thanks!
    Mark

    Hi Mark,
    After selecting data use this statement.
    DELETE it_table WHERE AFNAM is initial.
    Regards,
    Suneel G

  • Trying to edit a pdf - Is there a strikeover key for existing text to line through text without deleting the orignal text?

    I need to strike through existing text on a PDF I am trying to edit.  strikethrough like this but I cannot seem to locate this key  on the page where I am editing the pdf in adobe.
    Where do I locate this?

    Hi dhillionflygirl,
    You can find a Strikethrough tool on the Comment pane in both Reader and Acrobat.
    Please let us know if you have additional questions.
    Best,
    Sara

  • Rented movie is in a cycle when downloading and cannot get to download fully. Need to download fully or cut my losses and delete the rental. How can I do this?

    I bought an APPLE TV. Netflix and all works fine, until few days ago when I try renting out a movie in Apple store and the rent out proccess whent well, though "probably" due to my network speed (2Mb), the movie cannot be downloaded, it freezes at certain point and start back again. I have spent $5.00 renting out this movie; and although I will like to solve this problem, I am currently thinking on cutting my losses. How can I do to eliminate this from downloading in my Apple TV?
    It just seems impossible as I have restarted, reseted my apple TV and still this is downloading, therefore slowing down my network.
    Please help,
    Omar

    Huh.. Interesting. I went back to check these proceedures and found there is a difference between using the return key or the space bar as the action command.
    tabbing the blue ring moves the selection and then spacebar takes that action. The return key takes action of only the blue collored button.
    .... learn somting new every day, even if it is somthing I previously forgot

  • After creating a new login (bought computer used) and deleting the old one the 500gb hard drive only shows up as 320gb.

    So I've just purchased a mid 2011 Macbook Pro 13" used via eBay. Was advertised as having 500gb hard drive and 6gb ram. I checked the ram and it was all legit, checked the hd capacity and it was all correct as well. So I made a new login for myself and deleted the previous owner's. Now my hard drive shows up as 320gb. Even in disk utility and terminal.

    One more place to look is SYSTEM PROFILER>HARDWARE>SERIAL-ATA.  If it says 320, you have a 320GB HDD which I suspect it probably will.  They are easy to replace.
    Ciao.

  • Import and flow the xml text in a indesign document

    pls,anyone give me a solution for import and flow the xml text in a document.
    thanks,
    screen410099

    See http://forums.adobe.com/thread/838745?tstart=0
    Would you mind waiting a bit before asking again and again and again and then again? It's possible the person who can answer you question just didn't happen to read the forums this week.

  • About the bat file to start and stop the weblogic server10.3

    I am using windows 2003 os.
    i installed the WLS 10.3 .
    can anyone help me how to write the bat file for starting and stoping the weblogic server instance.so that it willl run as background service.
    I am new to this .Please suggest me
    Any help is appreciated.
    Thanks
    Sailaja.

    Hi David,
    yes.i am talking about Admin server.
    when i am creating the new domain,i didn't encounter any prompt asking me to run the Admin server as windows services.why i am not getting this prompt?where exactly i will get this prompt while creating domain.
    i am using the weblogic 10.3
    how can i make the admin server as windows services.
    Thanks
    Sailaja.
    Edited by: sj0609 on Dec 2, 2008 4:02 PM

  • Finding multiple strings in a text file and deleting the entire line

    Get-Content c:\output-Copy.txt | Where-Object {$_ -notmatch 'something1', 'something2', 'something3', 'something4' } | Set-Content temp.txt
    Above is the program that when it has 1 argument in the -notmatch part will find the specific string and delete the entire line. I need to be able to use multiple strings for my search, I am totally drawing a blank on this and I know its something REALLY
    simple but my brain is fried. The above code will work IF i only leave 'something1' and delete the rest. I need to find MULTIPLE matches and remove them all at once, what is a good way to accomplish this.

    You can use an alternating regex, like this:
    Get-Content c:\output-Copy.txt |
    Where-Object {$_ -notmatch 'something1|something2|something3|something4' } |
    Set-Content temp.txt
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • Acrobat X Pro crashed and deleted the file

    I am using Acrobat X Pro 10.1.3 in OS X 10.1.1.
    I was working on a file. Acrobat crashed without warning and reopened. It did not reopen the file. I looked in the Open a Recent File dialog box and in the Recently Opened menu, and my file was not there. I then looked for the file in the OS X Finder, and it appeared there as a blank file, but then--when I highlighted it--the file icon disappeared. I restarted Acrobat, and THIS time the file appeared in the dialog box and the Recently Opened menu, but when I selected it, I got a File Not Found message.
    I also did a search on the entire Mac for my file and it is absolutely gone.
    The problem isn't just this file--it's that it could happen to any file I am working on. The only work-around I have for now is to break large files into smaller parts by extracting the pages, so that if I lose a file, the damage is not as bad. But that's ridiculous.
    This file had been saved. Repeatedly. Didn't make any difference. Does anyone have any ideas?

    I'm not sure the size is right, but this is the sort of thing many people see, so don't be concerned.
    One cause of much bigger size than expected is that, as well as the programs themselves, there are also the information used to install and update.

  • HT5731 After following the instructions to clear a -50 error and deleted the .tmp file, I am now getting a -150 error. What next?

    After folling the instructions to clear a -50 error and deleted the .tmp file, I now am getting a -120 error. I can't find instructions to clear this...What next?

    Hello jimlcoff,
    I found a couple of articles with steps you can take when you are not able to connect to the iTunes Store.  I recommend reviewing the following articles:
    Can't connect to the iTunes Store
    http://support.apple.com/kb/TS1368
    iTunes: Advanced iTunes Store troubleshooting
    http://support.apple.com/kb/TS3297
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • I have an iphone 3g and my itunes wont back it up anymore. after the sync it says "itunes could not back up the iphone because the file has been corrupt or is not compatible with the device." i already went to prefrences and deleted the old back up file.

    nothing works. ive also tried to update my phone and it tells me it cant reach the server and to check my network settings or try again later =[ i dont know what to do and im furious!

    I banged my head on the wall with the same problem for two days.  Tried everything mentioned, and this worked, finally.  The problem is that the backup files are not where you think they are.
    You need to delete the MobilSync backup folder.  I have a Mac.  Went to /Library/Application Support/MobileSync/Backup and deleted the Backup folder. 
    Fixed the problem.  Give it a try and good luck!

  • Function module to choose the file for download and upload

    what is the function module to choose the file for download and upload  for presentation server.
    give me with example

    Please search in SCN.
    This has been discussed so many times.

  • Will not print files from mobile phone says it **may have** a virus- and deletes the file

    My HP photosmart premium with wireless ePrint, will not print files from mobile phone says it **may have** a virus- and deletes the file?!? My Fiance has the same phone, and I used it. It completed the file??? If I text message and E-mail address, my cell phone will come up as and E-mail address... has anyone else had this issue? Is it because I texted the the file? It didn't seem to be and issue on any of the other mobile phones used.... I am out of answers.... I tried to E-mail as well...
    Thanks in advance

    I have nearly the same problem, the printer discards my print job even when i have entered my email address as authorised senders.
    Details from my other post:
    I sent 2 emails to the printer:
    - one is a 3 lines of text and numbers in a GIF file sent as an attachment
    - another is a jpg circuit diagram paste in a word doc sent as an attachment
    both are classified as spam and refused to print. i have no email coming back saying it failed (even i have checked "Email Job Status" in ePrint Settings.
    So what will this HP printer print?
    How can I switch this useless spam filter off?
    I have get this filter off! I need this email printing to work reliably, that is a major reason I bought this printer
    Any suggestions are welcomed...
    HP's slogan on the box:
    "Now you can print from virtually anywhere" (but get discarded every single time!)

Maybe you are looking for

  • Camera not recognized

    For some reason, when I connect my camera to my iMac, iPhoto opens automatically, which I want it to do, but the camera does not show up in iPhoto. In fact "devices" isn't even displayed. Yet, when I open up Image Capture, it detects my camera. Does

  • Inserting date in the database

    Hello! I am getting one error ie SQLException which says"Optional feature not implimented ",while inserting date in a table in a database using PreparedStatement.setDate() method.please help me because of this one error my entire project is not movin

  • Fusion drive sound issue

    I just bought a new iMac to record music and do graphic design. I was told to buy the fusion drive as it's faster and better etc, so I did. To my surprise, there's a terrible crackling noise after 10 minutes or so when I'm playing music through my qu

  • 1 configuration file for all control files

    I happen to use sqlldr many times in my automation work. Most of the times few things in all my control files are same like LOAD DATA FIELDS TERMINATED BY ',' TRAILING NULLCOLS However if for some reason, something like delimiter changes, then I have

  • Power Point slide resized in Captivate

    Hello Forum, I'm testing Captivate 5 and am trying to convert an existing .ppt presentation into a Captivate module. However, one slide in particular seems to have been resized in such a way that the image which would normally fit below the text in .