Wednesday, 22 May 2013

Example of "for" loop in ksh and echo for special characters

Let's assume that we have a set of scripts in the current directories, all with .sql suffix and we want to print 2 lines of the beginning of each such script.

We'll use the "for" loop in ksh and we'll also use the escape character "\" to print the special character: "


>for f in `ls *.sql`
> do
> echo "set appinfo on" >> 1
> echo "select sys_context('USERENV', 'MODULE')  as \"Running Script\" from dual;" >>1
> cat $f >> 1
> mv -f 1 $f
> done

No comments:

Post a Comment