![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| concatenate files sorted by date | docaia | Shell Programming and Scripting | 2 | 08-15-2008 11:23 PM |
| How to concatenate 2 files using awk? | pdtak | Shell Programming and Scripting | 2 | 03-12-2008 09:12 AM |
| Concatenate text of two files in UNIX. | Uniq | UNIX for Advanced & Expert Users | 1 | 01-19-2007 03:53 AM |
| How to concatenate all files. | s80bob | UNIX for Dummies Questions & Answers | 1 | 08-22-2005 01:20 PM |
| Split n then concatenate files. | praveen.pinto | UNIX for Advanced & Expert Users | 4 | 02-15-2005 08:50 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Script to concatenate several files
I need a script to concatenate several files in one step, I have 3 header files say file.S, file.X and file.R, I need to concatenate these 3 header files to data files, say file1.S, file1.R, file1.X so that the header file "file.S" will be concatenated to all data files with .S extentions and so on for "file.X" and file.R with the .X and .R data files..
I tried using wild cards, like: cat file.S file[1-50].S > file[1-50].SP but I got a message saying that file[1-50].SP does not match so can this be done through a script? this will save a LOT of time for me, so if someone can help me it will be much appreciated |
| Forum Sponsor | ||
|
|
|
|||
|
These are basic shell loops, you should read some books or tutorials about scripting. To learn scripting is to read about it and try to find things out yourself.
Echo the variables within the loop like: Code:
for letter in S R X
do
for i in file[0-9].$letter
do
echo file
echo $letter
echo file.$letter
echo "$i"P
echo "$i"
done
done
Here you can read something about loops and variables (Googled on 'ksh scripting tutorial'): KSH script BASICS Regards |
|||
| Google The UNIX and Linux Forums |