e.g.
./consolidate.sh newfile.csv file*
will consolidate file1 file2 file3 into newfile.csv with the header once.
Main Topics
Browse All TopicsCan you please provide me with a shell script that does the following task?
In a given file path location there may be one or more text files with different
file names but with the same column headers and layout.
For example File1 contains data like;
COLUMN1 COLUMN2 COLUMN3 COLUMN4
12345,2222,121,J.Asobia
32311,,12111,Thomas Cook
File2 contains data like;
COLUMN1 COLUMN2 COLUMN3 COLUMN4
12345,2222,121,A.Dewnski
32311,,12111,King Street
And so on...
All these files needs to be consolidated into one file File3 without the column headers.
12345,2222,121,J.Asobia
32311,,12111,Thomas Cook
12345,2222,121,A.Dewnski
32311,,12111,King Street
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I am sorry as below was not my initial request.
I will not know the file names and there may be one or more files in a specific file location (which I know).
The shell script needs to pick up any file/files that are there in a specific file path location and merge
all the file/files into a file name "TAK123.txt".
Please help me with the shell script.
Thank you.
cakuzo:
I am really sorry but this is what I was asked:
There is a "START" folder within which there will be one or more files.
The shell script has to pick each file within the "START" folder.
Then call a Oracle stored procedure with the file name as input parameter.
sp_ins_table(file name);
If the Oracle stored procedure is successful then the file has to be moved to "FINISH" folder.
If not then the second file is picked and the process continues until all the files are processed.
Please help me.
Thank you
Now this is something very different than your request before, you didn't told anything about a oracle stored procedure.
However, you will need to connect to that DB for example with sqlplus, therefore also a connection string will be needed ... sqlplus -s DBUSER/PASSWORD@DBNAME
Where DBNAME is usually a tnsname identifier or SID, which is usually defined in /opt/oracle/product/<VER>/ne
My script above does exactly that what you described first. But now your request transformed to something different. I would suggest you to close this question and open a new one for the other thing.
Business Accounts
Answer for Membership
by: omarfaridPosted on 2009-09-22 at 15:06:19ID: 25398068
try
cat file1 file2 file3 > newfile
If you are not sure about their number then you can do
cd /path/to/dir
cat file* > newfile