Give extensions to files which do not have an extension

HI,

I have a bunch of files on my Linux system which do not have a file name extension in them. I want to process them with "sed" (using loop) but can't do so. Is there any way to give an extension to files which have no extension in them in Linux?

Currently files are like this:

cat
dog
elephant

But I need to add extension so that they become:

cat.dat
dog.dat
elephant.dat
#!/bin/ksh
for i in `ls path`
do
    mv $i $i.dat
done

path is the path where your files exist

1 Like