reading multiple files

Hello

I have a requirement where i have to loop through certain directory which will have multiple files. After looping through i have to make a list of file names exisitng in the directory and write them to a sequental file and each file should be delimited by ^%^

i.e If i have 3 files A, B,C in a directory called Files then i have to loop through the Files directory and write the file names to a .txt file with each file name is delimited by ^%^ as below

A^%^B^%^C

Regards
Dsdev_123

One way:

cd /directory
ls | awk '{ printf("%s^%%^", $1) }' | sed 's/\^\%\%$//' > /path/to/file.txt

Try this:

 ls | awk '{printf "%s%s", NR==1?"":"^%^",$0}'

Hi when i executed this i am getting
A^%^B^%^C^%^

The last filename should not get ^%^ at the end.

Thanks for your reply