Page 1 of 1

Need help with a simple srcipt

Posted: 29 Sep 2011 13:09
by dtalex
Hi all
can you please help me converting thi simple script from bash to batch?

Code: Select all

for element in `ls | grep .sql` 
do
   cat $element >> scriptino.sql
done


I just want to put the output of all .sql files in a directory
in anoither sql file in the same directory

Thank you

Re: Need help with a simple srcipt

Posted: 29 Sep 2011 13:54
by dbenham
Everything below assumes you are running the command or script from the directory with the .sql files, as does your script.

From the command line:

Code: Select all

(for %f in (*.sql) do type "%f")>scripino.sql

Within a script (.bat or .cmd file)

Code: Select all

(for %%f in (*.sql) do type "%%f")>scripino.sql


Both the above will include the TYPE command with filename above each file contents. If you only want the file contents then we need to disable the echoing of the command:

from command line:

Code: Select all

(for %f in (*.sql) do @type "%f")>scripino.sql

Within a script:

Code: Select all

@echo off
(for %%f in (*.sql) do type "%%f")>scripino.sql


Dave Benham

Re: Need help with a simple srcipt

Posted: 29 Sep 2011 14:37
by dtalex
Thank you Dave

dbenham wrote:Everything below assumes you are running the command or script from the directory with the .sql files, as does your script.


What I want to to is just double click on it (already placed in the directory i'm intrested) and run the output file in sql developer ('/' are already included in sql files)