Shell script request

I've a master file which will contain 100 file names, The script should read file name from a master file and format the file as below in AIX.

input file

Filename

This
is
a
test
file

Output File

Filename|This is a test file

Thanks in advance

for file in $FileList; do 
echo $file; 
FileName=`basename $file`; 
sed  's/^M//g' $file> "${file}"2;
mv "${file}"2 "${file}"; 
sed '1d'  "${file}" >"${file}"1; 
mv "${file}"1 $file; 
sed 's/^$/|/'|tr "\n\r" "  " > "${file}"1
mv "${file}"1 $file; 
done

This is doing nothing. I'm not good at sed. Please help.

what have you tried? where do you need help?

What Operating System and version do you have? What Shell do you use?

You seem to refer to ^M a lot (which I interpret as intending to mean ctrl/M or carriage-return).
Is the input file a Microsoft format text file with carriage-return line-feed at the end of each line? Or is this a normal unix text file with just line-feed at the end of the line. Or is this an old MAC format text file with carriage-return at the end of each line?

Does Filename occur at the top of each file called Filename?

Hi

I'm using bash shell in AIX 6.1
^M microsoft text
Yes its a Microsoft format text file with carriage-return line-feed at the end of each line

No the file name I've mentioned in example will be a free test like "Null in a Not Null column" or "0 Length Char". This will be standard in all files.

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.

Duplicate topic, continue here.