I know its a newbie question, but my bash knowledge is so limited. Any help with this script? Thanks.
Trying to join files from three directories into a single file like:
<directory1>
header.txt
footer.txt
<directory2>
050421.txt
050420.txt
050419.txt
...
<directory3>
050421.txt
050419.txt
...
Result would be:
### final.file start
header.txt content ## from directory1
050421.txt content ## from directory2
050421.txt content ## from directory3
050420.txt content ## from directory2
050419.txt content ## from directory2
050419.txt content ## from directory3
footer.txt content ## from directory1
### final file end
As you see file names are in format %y%m%d and must be appended to final.file ordered by date.
If name exists in both directories, file from directory2 goes before file from directory3.
Sometimes a filename exists only in directory2 and not in directory3 so next file from directory2 must be appended to final.file
Trying to join files from three directories into a single file like:
<directory1>
header.txt
footer.txt
<directory2>
050421.txt
050420.txt
050419.txt
...
<directory3>
050421.txt
050419.txt
...
Result would be:
### final.file start
header.txt content ## from directory1
050421.txt content ## from directory2
050421.txt content ## from directory3
050420.txt content ## from directory2
050419.txt content ## from directory2
050419.txt content ## from directory3
footer.txt content ## from directory1
### final file end
As you see file names are in format %y%m%d and must be appended to final.file ordered by date.
If name exists in both directories, file from directory2 goes before file from directory3.
Sometimes a filename exists only in directory2 and not in directory3 so next file from directory2 must be appended to final.file