Re: [dev] print utility

2013-04-02 Thread markus schnalke
[2013-04-03 16:25] Sam Watkins > > using awk this seems to work: > > awk '{ gsub(A, B); print; }' A="$A" B="$B" > > Still a bit long, but much better than I can manage in sed or perl. Not sure > if that is standard awk or not, there's also a -v option to set values. Your version is the orig

Re: [dev] print utility

2013-04-02 Thread Sam Watkins
> What is the shortest shell command you can write, that replaces $A with $B in > a text stream for any A and B? On Tue, Apr 02, 2013 at 06:32:19PM -0700, Noah Birnel wrote: > A1="$(printf '%s' "$A" | sed 's,",\\",g; s,\\,,g')" > B1="$(printf '%s' "$B" | sed 's,",\\",g; s,\\,,g')" > awk '

Re: [dev] print utility

2013-04-02 Thread Noah Birnel
On Tue, Apr 02, 2013 at 04:29:59PM +1100, Sam Watkins wrote: > > What is the shortest shell command you can write, > that replaces $A with $B in a text stream for any A and B? > A1="$(printf '%s' "$A" | sed 's,",\\",g; s,\\,,g')" B1="$(printf '%s' "$B" | sed 's,",\\",g; s,\\,,g')" awk '{

Re: [dev] print utility

2013-04-02 Thread Roberto E. Vargas Caballero
> > Please don't write this tool as it is already available: ed(1): > > echo '1,$-6p' | ed - "$1" > echo '10,$--p' | ed - "$1" better: ed -s $1 <<"EOF" 1,$-6p EOF ;)

Re: [dev] print utility

2013-04-02 Thread Bjartur Thorlacius
Do note that gres(1) lives on as replace(1). Replace is maintained by the MySQL team.

Re: [dev] print utility

2013-04-02 Thread Sam Watkins
On Tue, Apr 02, 2013 at 01:29:11PM +0200, markus schnalke wrote: > [2013-04-02 15:23] Sam Watkins > > > > I suggest to extend your program so it can also print a range of lines > > (and thus subsume the functions of 'head' and 'tail' while doing more > > and yet staying fairly focused). You coul

Re: [dev] print utility

2013-04-02 Thread hiro
Sam Watkins was just testing him, now you spoiled it, lol. On 4/2/13, markus schnalke wrote: > [2013-04-02 15:23] Sam Watkins >> >> I suggest to extend your program so it can also print a range of lines >> (and thus subsume the functions of 'head' and 'tail' while doing more >> and yet staying f

Re: [dev] print utility

2013-04-02 Thread markus schnalke
[2013-04-02 15:23] Sam Watkins > > I suggest to extend your program so it can also print a range of lines > (and thus subsume the functions of 'head' and 'tail' while doing more > and yet staying fairly focused). You could perhaps use negative numbers > to count back from the final line. It sho

Re: [dev] print utility

2013-04-02 Thread markus schnalke
[2013-04-02 15:36] Sam Watkins > I reckon by far the most common thing people do with sed is to replace > one (sort of) string with another. But even this "core sed business" > is ridiculous with sed. > > e.g. A=/usr/bin B=/bin sed 's/$A/$B/' out # won't work > > Changing delimiters doesn't