LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-30-2003, 01:34 AM   #16
Skyline
Senior Member
 
Registered: Jun 2003
Distribution: Debian/other
Posts: 2,104

Rep: Reputation: 45
Smile


Happy bunny!

Code:
#!bin/bash

y() { echo -e "\n\n" >> $compilation_file; }

echo - "Please type the path to the compilation file :"
read compilation_file
echo "Please type the original files that are going to make up the compilation file :"
read -a original_files
for i in ${original_files[*]}
do
cat $i >> $compilation_file
y
done

Success at last - I've got the for-loop working - I'd forgot the $ sign before i in cat $i - script works great now and can concatenate any number of files easily and neatly into one final file - thanks to Strike for the original pointer.
 
Old 08-30-2003, 07:07 PM   #17
Skyline
Senior Member
 
Registered: Jun 2003
Distribution: Debian/other
Posts: 2,104

Rep: Reputation: 45
Just a little update to my script - can now put filenames straight from the array to the top of each file with a neat single blank line.

echo "$i" >> $compilation_file ; y


Code:
#!bin/bash

y() { echo -e "\n" >> $compilation_file; }
z() { echo -e "\n\n" >> $compilation_file; }

echo - "Please type the path to the compilation file :"
read compilation_file
echo "Please type the original files that are going to make up the compilation file :"
read -a original_files

for i in ${original_files[*]}
do
echo "$i" >> $compilation_file ; y
cat $i >> $compilation_file ; z
done
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash scripting help (su ...) shwong Linux - General 1 11-02-2005 12:26 PM
Bash scripting pete1234 Programming 1 09-27-2005 01:48 AM
bash scripting vadon Linux - Newbie 6 05-10-2005 04:07 AM
need help with bash scripting rich2oo1 Programming 2 12-17-2003 12:50 PM
HELP with BASH scripting atwah Linux - Newbie 6 09-09-2003 01:10 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration