Home / How to search for text files in a directory and add .txt suffix to their filenames?

How to search for text files in a directory and add .txt suffix to their filenames?

On the bash command line, run the following command to search for text files in a directory and add .txt suffix to their names.

# for i in $(file * | grep ASCII | awk -F : {'print $1'} | xargs); do mv "$i" "$i.txt"; done

Leave a Reply