I am trying to write a very simple bash script in order to add a file extension (.java) to a bunch of files that have no extension.
If they had an extensions (say .txt) I’d do this:
#!/bin/bash
for file in `*.txt`;
do mv $file $file.java;
done
My files, however, don’t have an extension. How do I make the loop? I tried *. with no luck.
Thank you.
If you only want to move files that do not already have an extension, try:
Note that all of the double-quotes above are superfluous if your filenames are reasonable.