Script to create a text file whose content is the text of another files

Hello everyone,

I work under Ubuntu 11.10 (c-shell)

I need a script to create a new text file whose content is the text of another text files that are in the directory $DIRMAIL at this moment.

I will show you an example:

  • On the one hand, there is a directory $DIRMAIL where there are the following files at this moment:

First file = 1332348161.2848_1.lab0_2,
Second file = 1332348161.2848_11.lab0_2,ST
Third file = 1332355415.3771_47.lab0_2
Fourth file = 1332404735.3771_53.lab0_2,

as you can see, each file always includes the word "lab" and for example its content is plaintext such as:

1332348161.2848_1.lab0_2,
first file's text
1332348161.2848_11.lab0_2,ST
second file's text
1332355415.3771_47.lab0_2,
third file's text
1332404735.3771_53.lab0_2,
fourth file's text

  • What I am trying to achieve is a script to create a new file called Inbox in another directory $DIRINBOX, whose content would be the result of adding the text of each file, I mean, the following text in this case:

Inbox
first file's text
second file's text
third file's text
fourth file's text

  • On the other hand, after creating Inbox file in this way, I need all the files included in $DIRMAIL.

Probably it may be a very easy script but I am a beginner and don't know how to do it. Any suggestion please

Thanks in advanced.

Files will be output in alpha order of filename

if ls $DIRMAIL/* 2> /dev/null
then  
    cat $DIRMAIL/* > $DIRINBOX/inbox
else
    echo No Files found in $DIRMAIL
fi