[Gllug] Batch Text Replacement

Tethys sta296 at astradyne.co.uk
Mon Oct 29 19:06:51 UTC 2007


--------

"Henry Gilbert" writes:

>> Why?
>
>In this case, there is a lot of code to be annihilated that include
>carriage returns.
>
>Consider a snippet like this:
>
> [...]
>
>Now to delete such mess but not delete other tables or messes .. I could
>either:
>
>A) Think of some unique matching key so that whole thing gets deleted
>somehow in CLI. (500 Brain-KCals)
>
>B) Or I could copy and paste on some nifty GUI and click Replace. (10
>Brain-KCals)

This is easy in sed[1]. If you're doing any halfway serious text
manipulation, you're doing yourself a disservice if you don't equip
yourself with the right tools, starting with regular expressions,
and a suitable tool for using them. In this case, sed would be my
tool of choice. Others may suggest awk, bash, python or perl. All
equally valid choices[2].

Your "nifty GUI" probably doesn't exist, and for good reason. There
is no way you'll be able to replicate the power of the command line
in a GUI. So perhaps someone has written a GUI tool to cover the
common cases (I haven't looked, so I can't say). But a common usage
pattern for one user might be a once in a lifetime activity for
another. So which features should this hypothetical GUI include?
And what happens when you want to do something that isn't covered
by the features included in the GUI? With a command line tool, you
can just combine it with something else that does the job (assuming
your command line tool doesn't already include that functionality).
With a GUI, you're screwed.

Tet

[1] Assuming the first line of your multiline statement gives you
    enough information to recognise it as such. If you need to parse
    successive lines to determine if the table needs deleting, then
    it requires a bit more work.

[2] With the usual "perl is evil and must die" caveat, of course :-)
    Sorry, Aaron, I couldn't resist...
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list