Re: regex, negations, grep, find and replace (a few questions)



jameshanley39@xxxxxxxxxxx wrote:

Is there anything like grep that does not have this problem/feature
? or where that problem/feature can be turned off?
Use -o (man grep). For the multi-line problem, just remove the
newline characters before piping the text to grep, eg

echo $text | tr -d '\n' | grep 'your_pattern'

that is really interesting, thanks..
that -o is ideal (and that tr command also shows me how to convert
windows-->unix , since it just involves removing the CR '\r')
note- that command would return all $text or all the file, since you
missed the -o from grep. But I only know about -o since you mentioned
it! I think you intended to include it.

Of course, it escaped me. The -o has the added benefit that if multiple occurrences of the pattern occur in the same line, grep outputs them separately, eg

$ echo "helloblahhello" | grep -o hello
hello
hello

I actually dealt with this find/replace or extraction problem by using
the regex I mentioned, but with grep -o , making a new file.
Then, since it was intented html code I used an old feature of MS Word,
which is probably in linux`s Open Office too. I made the font Courier
(a fixed width font). I held ALT and highlighted in a rectangle, what
I wanted to select, and removed characters i did not want from each
link in one go. I made the font size tiny and the zoom high, to
remove wordwrap.

With OO you can do search/replaces using regexes, something that office cannot do (and won't likely do in the future either, imho).
.



Relevant Pages

  • Re: shell scripting with solaris, help.
    ... only if filenames don't contain newline characters (which is ... awk can do the job of both grep and wc -l, ...
    (comp.unix.solaris)
  • Re: MacTeX 2007 and documentation
    ... may be the most useful command available when doing searches at the ... will find every file on your system that has the text "memoir" on it, ... If locate generates 30 lines of text, where each line is a file, grep ... I need a Unix guru to chat to for half an hour or so to put me straight. ...
    (comp.text.tex)
  • Re: piping multiple selections to mv or cp and exclusion
    ... pipe to shell to execute each command statement ... Unix is indeed lifelong learning :-) ... and the regexp. ... back into the grep statement. ...
    (comp.unix.shell)
  • Re: MacTeX 2007 and documentation
    ... means you need expertise in your host operating system as well. ... locate memoir | grep pdf ... I'm not someone who lives at the command line, ...
    (comp.text.tex)
  • Re: Program to scan directories
    ... Is there a UNIX command which scans directories and execute any other ... the regex you specify here is /not/ given to grep to ... entries (files and subdirectories). ... tell grep to recurse through the kpathsea directory (the *.h regex ...
    (comp.unix.programmer)