General :: Emacs - Search And Replace Regex In Multiple Buffers?

Apr 7, 2009

I'm fairly comfortable with emacs but I can't seem to find how to do this. I deal with a lot of text files and find myself performing a lot of regular expression replacements to correct the formatting of the text -- or to extract certain tidbits of data from large ugly-looking files.

I know how to perform a regular expression replacement in one buffer at a time. But how do you perform a regular expression search and replace across all open buffers? I have found a method to perform a regex search and replace across a directory by marking files but I need to do it in the open buffers.

View 2 Replies


ADVERTISEMENT

General :: Search And Replace Line In Multiple Files?

Jul 13, 2010

Hello, I need some help searching through multiple files, finding a line and replacing that line. The line I am searching for is:

password key ******* 1222554

ultimately I want to be able to delete the numbers after the asterisks . my thoughts are to create a script that will search for the line password key ******* and delete it then replace it with password key ******* my files are located in /opt and they are all txt files.

View 13 Replies View Related

General :: Search And Replace String Having Multiple Special Characters

Aug 26, 2009

Below is extract of my file:

What I need is to replace "--destination-path=" with "--destination-path=/home/dest"

i.e. desired output is ----destination-path=/home/dest

I could achieve it with below command

$cat outgoing-xfer|grep destination-path|perl -pi -e "s/destination-path=/destination-path=/home/dest/g"

But the problem is that in this case i just wanted to append "/home/dest" for which I could easily escape "/" with just two "", but I wonder if i have a long path like "/a/b/c/d/e/f/g/h/i/j" I will have to escape so many /. Is there any other way by which I can avoid escaping forward slash.

I tried following:

But receiving follo error

Bareword found where operator expected at -e line 1, near "s/destination-path=/'destination-path=/home"
syntax error at -e line 1, near "s/destination-path=/'destination-path=/home"
Bad name after dest' at -e line 1. tried with enclosing in double quotes as well but in vain

View 5 Replies View Related

Ubuntu :: Text Editor Column Editor And Regex Search/replace, Incrementing Number Insert?

Jul 25, 2011

On windows I really only used Notepad++ as my text editor, it had two features that I loved.What I need to accomplish is what I would do with Notepad++ column editor.I could have like 100 lines, and place the cursor at a column, and goto edit>column editor, and I could insert an incrementing number. (I could also pad the incrementing number with 0s, this was GREAT for making batch files among other things.)So each line at that column had a number higher than the previous line.The other feature that I used sometimes was a search/replace with regex patterns.Does anyone know of an editor that has those features for linux? I am mostly after the column editor insert feature but if you know of one with both features that would rock.

View 1 Replies View Related

Programming :: Awk Multiple Line Search And Replace?

May 1, 2011

I am trying to search and replace a multi line pattern in a php file using awk.The pattern starts with

<div id="navbar">
and ends with
</div>

[code]...

View 3 Replies View Related

Ubuntu :: Multiple Search And Replace In Documents - Creating A Sed Script?

Jul 16, 2011

I want to do search and replace in multiple files. I've seen that it possible to create a sed script but I haven't got the talent to do it myselfWhatd is to locate all instances of a word - lets say 'day' - and replace it with for example 'night' in all odm-documents in a specific folder. It would be great if the search only matched whole words and was case sensitive.

View 1 Replies View Related

General :: Web Search Engines And Emacs / Vim

Nov 8, 2010

The facilities offered by any text editor to look for a string are highly superior to those offered by search engines such as that of Google or the one used by LQ>Search. To only speak of the most one elementary that comes to my mind, you can reach 'john smith' by searching with the string 'hn smi' in any decente editor, but I know of no search engine that offers this feature.

On the other hand, I have always heard of the power of Vim and Emacs. For instance, they say there is no thing Emacs cannot do. Lets advocate to the job of adding Google searches the ability to find 'john smith' by using 'hn smi' as the matching pattern. Or to add regular expression capabilities. Could I use Vim/Emacs to solve this problem?

A little light into the meaning of my words: It would be Vim/Emacs the one in charge of making the Internet connection, connecting to Google and send appropriate commands go Google. Then, to look for my string, I would be directly using Vim/Emacs which, upon receiving my commands, would send the appropriate ones to Google and return control to me.

View 2 Replies View Related

General :: Search And Replace /'s In VI

Feb 7, 2010

I was wondering how I would search and replace all /'s with -'s in vi. %s///-/g doesn't work obviously.

View 2 Replies View Related

Ubuntu :: LibreOffice Regex - Replace [:alpha:]$

Jun 20, 2011

My friend lost her dissertation and she had only a pdf copy of it. I am trying to convert the pdf into an odt format. After copy-pasting the content into an odt, i need to replace all paragraph breaks which are not following a dot with a space. For which i thought of using the regular expression feature of Libre Office. I've not succeeded so far.

I tried: to replace [:alpha:]$ or [a-z]$ or [a-z]>$ with space, but none of them worked. Finding [a-z] seems to work, finding [a-z]> too. So did finding $ (end of paragraph) but if i combine any regex with $ then it doesn't find anything.

View 7 Replies View Related

Programming :: TBP ERROR: No Buffers Available In Free Buffers List

Jan 8, 2010

I am trying to test a Gigabit Ethernet Tattile line scan camera. I installed the driver properly set the ip of device using utility given in the driver. when i am trying to open the live view of camera using a utility given (tag_show) it gives me error in /var/log/messages TBP ERROR: No buffers available in free buffers list When i looked into the code of utility it is doing ioctl call where it is failing with errno=12.

View 4 Replies View Related

General :: Search Multiple Words In Multiple Lines?

Dec 16, 2010

How to search multiple words in multiple lines, inside a directory including sub-directory? Pls. give easy example. I want to search the files (in /xx folder and all subfolders) that have header.h included and used x() function. I tried $grep -r "header.h" | grep -r "x(" /Folder/subfolder/ > search.log

View 7 Replies View Related

General :: Regular Expression In VIM Search And Replace?

Oct 22, 2009

I have two type of lines in a text file example

Code:

x.junk(a,b,YAHOO);
y.junk(c,d);

I want to search and replace the second type of line with the first type i.e. with YAHOO included, so that I have

Code:

x.junk(a,b,YAHOO);
y.junk(c,d,YAHOO);

I am trying to use

Code:

:%s/(.*).junk((.*),(.*)^<YAHOO>);/1.junk(2,3,YAHOO);/

In the above code ^<YAHOO> search is not working (I want lines "except YAHOO"). I know that [^ab] will work for "except a,b" characters. How can I say "except word" in regular expressions?

View 8 Replies View Related

Programming :: Construct A Quick Regex That Will Search For Six Lines Of Text

Apr 25, 2011

I am trying to construct a quick regex that will search for six lines of text without a clear line break between them. It only needs to search, not replace, as I will be using in gEdit (with regex plugin) anyway.

It's for editing subtitle files. The video player I will be using them on can only cope with 3-line subtitles, so I just need to edit any in the srt file that contain four or more. There won't be many so I can do it manually. For example:

26
00:01:47,357 --> 00:01:49,359
a motivated business
professional with
clearly defined goals.

[Code].....

but .* seems to mean "any character, or none", so that doesn't work. My experience of regular expressions is limited, but I do know they are very powerful when used correctly!

View 10 Replies View Related

General :: Regular Expression Search And Replace In Writer Or Gedit?

Oct 26, 2009

I've got a list of files that I've copied from my terminal and pasted into gedit and into OO.o writer. Since the files are all created by gedit, in each case there is both file and file~. I want to get rid of all the 'file~' lines. I thought I could do search and replace using *~, but this doesn't work.

View 4 Replies View Related

General :: Shell Script To Search One File For Contents Of Another And Replace Text?

Feb 3, 2011

Suppose I have a pair of files containing lists. The first file is called contigs.txt and it contains a list that looks like this:

Code:
Contig822
Contig826

[code]...

View 5 Replies View Related

General :: How To Open Multiple Files With Splitting Window In EMacs

Apr 21, 2010

What's the command to open multiple files in Emacs vertically/horizontally splitting window.

View 4 Replies View Related

Software :: Using EMacs Abbrev-Mode To Replace Symbols?

Jul 7, 2011

I want to use Emacs abbrev-mode to be able to replace certain programming symbols with their Unicode equivalents as I type. So, for starters, I added this to my abbrev_defs file:

Code:
(define-abbrev-table 'haskell-mode-abbrev-table '(
("->" "→" nil 0) ))

But it simply doesn't work when I am in abbrev-mode. No error message, the auto-abbreviation simply doesn't take place. If I adjust the above:

Code:
(define-abbrev-table 'haskell-mode-abbrev-table '(
("arrow" "→" nil 0) ))

Then auto-abbreviation works with the word "arrow". Why can't it auto-replace the symbol?

View 3 Replies View Related

General :: Replace Multiple Spaces By One Tab

Feb 2, 2011

Ive some textfiles which contains some colums seperated by a various number of spaces, but instead i need one single tab as a seperator.

View 5 Replies View Related

General :: Replace Multiple Instances From X To Y In Line

Feb 1, 2010

I have a line of text with multiple web links in the line. I'd like to replace the actual links with the text "<web-link>" so I don't accidentally hit them while reading on my iphone. I've tried many versions of the following sed command, sed 's/(http.*)/<web_link>/g', but it simply replaces everything between the first instance of "(http" and the last instance of ")" with <web_link>, or does nothing at all.

Ex: This line has a link to a web page (http://www.webpage.com/file.html) then some more text (extra text) and then another link (http://www.nextwebpage.com.index.html) to a website.
$ echo "This line has a link to a web page (http://www.webpage.com/file.html) then some more text (extra text) and then another link (http://www.nextwebpage.com.index.html) to a website." | sed 's/(http.*)/<web_link>/g'

What I get is: This line has a link to a web page <web_link> to a website.
What I'd like is: This line has a link to a web page <web_link> then some more text (extra text) and then another link <web_link> to a website.
What am I doing wrong with my sed command?

View 4 Replies View Related

Programming :: Sed Regex Get Multiple String Match In Array?

Apr 8, 2011

I have a sed match that matches for certain string of a regex expression:

Code:
tname=$(echo "$contents" | sed -n 'some pattern')

How do I match for multiple strings in the $contents and return them as an array? for example

Code:
contents="this is a text, just to match patterns, here is another text to be matched"
the sed func would be able to recognize both "text"s, but only one is outputted?

Possible to put it in an array? so ${bar[0]} gives one and ${bar[1]} gives another

View 3 Replies View Related

General :: Use Grep To Search For Multiple Options?

May 20, 2010

How can I use grep to search for line with either 'res' or 'rep'? i try "grep -e res|rep" or gre -e "rep|rep" but that does not work.

View 3 Replies View Related

General :: Find & Replace String In Multiple Files?

Jan 15, 2010

After hours (literally) of searching the web and reading man pages, I think I've come up with the following:Code:find . -exec grep 'path/to/file' -print | xargs -0 -I new_path mv {this is where I get confused}So my code above is incomplete, obviously. In order to finish replacing the string, I need to mv the new file into the old file's spot. How do I do this, by incorporating it into my line of code?

View 14 Replies View Related

General :: Replace A String In Multiple File & Sub Directories?

Aug 31, 2010

Need to replace the following string :

By

In multiple .exp files and in sub directories.

View 5 Replies View Related

Software :: Use Regex Or Pcre To Find Out The Matched From Multiple Textfiles?

Feb 7, 2010

I am trying to use regex or pcre to find out the matched from multiple textfiles. how to write a relative program on linux C?

View 3 Replies View Related

Programming :: Perl Regex Not Matching Across Multiple Lines Despite Ms Flags / Fix It?

Aug 16, 2010

I have written a regular expression (tested in regexpal and regextester alpha something) with which I want to replace something like code...

but it only matches functions which occupy one line only, despite my tests showing multiple line matching in javascript testers online and using the m and s flags (which should make it multi line no?)

View 14 Replies View Related

Programming :: Simple Regex For PHP Preg_replace() To Replace &nbsp But NOT &nbsp

Nov 16, 2010

I've got an incredibly simple regular expression need but I've spent several hours trying and even this insanely simple one is eluding me completely... All I want to do is, in a piece of text, replace   with   but leave all strings that are ALREADY alone. Eg. on one run of the regex on this

[Code].....

What will a proper PHP / PCRE regular expression look like that will replace all   with   but leave all the already existing (e. g. those that are already correct) in a string alone? this appears simple (at least to me) but I've invested several hours into this and still no solution. I suspect for an expert it is incredibly simple...!

View 2 Replies View Related

General :: Search For Text Strings In Multiple PHP Files?

Feb 3, 2011

Long story short, I got a folder with nearly 800,000 php files. I would like to search each file for a string and if it exists in that file, the file gets copied to another directory. Is this possible from the terminal? So far I got: grep -i -n -r 'ppr-1792' * | cp $1 move_to_here

But this obviously doesn't work. $1 needs to be the file name that contains matching text.

View 2 Replies View Related

General :: Search For A File In Multiple Machines Simultaniously?

Sep 15, 2010

Im new to the forum and fairly new to Linux as well. my apologies if this is posted in the wrong section. My problem is How can you search for a file in multiple machines (like a server farm) ? For example i log onto machine num1 and want to search for a file named "xxx.yyy" which may be in one of 4 machnies. What i do right now is manually log into each machine and run the find command. However i have heard that it is possible to do it via a couple of simple commands. I have looked into pssh and cssh as well as ssh tunneling (along with public key authentication to stop the machines requesting a password every time i log in) and unfortunately i was unable to find an answer.

View 4 Replies View Related

Ubuntu :: Replace Multiple Lines In Multiple Files?

Aug 20, 2011

I often use the rpl command to make changes to multiple html files at once. For example:

rpl -R '<br />' '<br /><br />' mydirectory However, I haven't been able to figure out how to change multiple lines. For example, let's say I want to change all occurrences of :

<br />
<br />
to:
<br />
I've tried
rpl -R '<br />
<br />' '<br />' mydirectory

but that didn't work. how to do this with rpl or some other way?

View 9 Replies View Related

General :: Search & Replace Back Slashes To Forward Slashes In Windows

Feb 11, 2011

Lately I've been needing to delete new untracked files from my versioning system. Being in linux I use: hg status -un|xargs rm And it works nice, but when doing it in windows, hg status lists paths with backslash so that is where stuff goes wrong. So then I try: hg status -un|sed 's/\///g' ...but I get the error: sed: -e expression #1, char 8: unterminated `s' command

Then I try some ascii: `hg status -un|sed 's/o134/o57/g'`...that gets me: sed: -e expression #1, char 14: Trailing backslash And some scripting: hg status -un|sed 's/`echo `/`echo /`/g' ...that gets me: sed: -e expression #1, char 19: unknown option to `s'

I try all the last with any other characters and I get the expected output... so I'm completely lost. I have cygwin, of course, and I want to avoid using a file (that is what I've been doing).

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved