Filename pattern match and appending pipe

Hi,

I have a directory with around 100k files and files with varying sizes(10GB files to as low as 5KB). All the files are having pipe dilimited records.

I need to append 7 pipes to the end of each record, in each file whose name contains _X3_ and need to append 10 pipes to the end of each record, in each file whose name contains _X7_.

I tried as below but it doesnt work, it changes for all files

for file in *
do
  {
    awk '{printf "%s,\"%s\"\n",$0,"|||||||"}' "$file"
    } > output && mv output "$file"
done

Thank You in advance
.

---------- Post updated at 12:57 PM ---------- Previous update was at 12:40 PM ----------

Thank you Franklin. Will use the Code tag in future.

try this.

 
for file in `ls *_X3_*`
do
    awk '{print $0"|||||||"}' $file> output 
    mv output $file
done

Or
if sed supports -i option

for file in `ls *_X3_*`
do
sed -i 's/$/|||||||/g' done
done

Useless use of ls, this is sufficient:

for file in *_X3_*

Thank you , I did the following:

for file in *_X7_*
do
    awk '{print $0"|||||||"}' $file> output 
mv output $file
done


for file in *_X3_*
do
    awk '{print $0"|||||||"}' $file> output 
mv output $file
done

any better way?

Also I have multiple level of directories with each directory. I need to do the change in each and every directory where i can find a file with the filename having _X7_ or _X3_

Thank you in advance