[Novalug] additional question on scripting

Sean McGowan scepticanagramwonk@verizon.net
Tue Mar 31 18:54:14 EDT 2009


you can show the difference in a file with 'diff file1 file2 > outfile'
(in your case this should only be one line)

or, if you want to see it before it kicks off use

xterm -e 'diff file1 file2 | tail -f'
or
xterm -e 'diff file1 file2 |tee outfile |tail -f'
will write the output to the STD_OUT and to outfile.

this will serve as a cheap popup and not give control back to your
original shell until you manually close the xterm (^C will close it).
You can probably do similar things with other terminals, but I like
xterm.  You can also command line any attributes you want xterm to have
(background color, size, title, etc., but I believe the -e has to be the
final option.


On Mon, 2009-03-30 at 14:39 -0400, Nino Pereira wrote:
> >> Normally I use as screen editor gedit, as line editor pico or nano.
> >> These don't do it (I think: I'd love to be corrected). But, I've
> >> seen people propose mysterious commands in sed or awk or their
> >> modern replacements. Could any of those do it?
> >>
> > 
> > vi/vim can be command line coded to execute a set of commands.  Eg.
> > 
> >  vim -c "23s/==ReplaceME==/$RANDOM/" -c "w newfile" -c "q!" infile
> > 
> > should create a new file with a specific string on line 23
> > changed to a shell created random number.
> 
> Your answers did the trick. Thank you.
> 
> Of course I didn't read the suggested commands at first, so
> I forgot the '>' that one of them needed, so it started to
> work only when I fixed that error. Now, the question is: how
> do you check, in the same script, that the substitution worked?
> 
> I'd like to wait for a few seconds, so that my program can do
> its thing and put out a file that reflects the change in the
> input file. So, the next question is: how do you make a script
> pause?
> 
> Before submitting this question I thought: why not google? And,
> this gives indeed the answer: the command
> 
> sleep n
> 
> stops the script for n seconds.
> 
> Thanks for the help. It's nice to know that there's backup
> to google.
> 
> Nino
> 




More information about the Novalug mailing list