As shown below, I have multiple files like below (query1-extract_aa, query1-extract_ab, query1-extract_ac, ....)
$ ls -l
total 235680
-rw-rw-r-- 1 reportusr reportusr 30M May 3 11:25 query1-extract_aa
-rw-rw-r-- 1 reportusr reportusr 30M May 3 11:25 query1-extract_ab
-rw-rw-r-- 1 reportusr reportusr 30M May 3 11:25 query1-extract_ac
-rw-rw-r-- 1 reportusr reportusr 30M May 3 11:25 query1-extract_ad
-rw-rw-r-- 1 reportusr reportusr 30M May 3 11:25 query1-extract_ae
-rw-rw-r-- 1 reportusr reportusr 30M May 3 11:25 query1-extract_af
-rw-rw-r-- 1 reportusr reportusr 30M May 3 11:25 query1-extract_ag
-rw-rw-r-- 1 reportusr reportusr 22M May 3 11:25 query1-extract_ah
I want to append .txt to the end of these filenames , so that
query1-extract_aa will be renamed to query1-extract_aa.txt
query1-extract_ab will be renamed to query1-extract_ab.txt
query1-extract_ac will be renamed to query1-extract_ac.txt
.
.
.
etc...
after the first for...mv run when all files disappeared there should be a file in the directory called .txt (since $1 was not set) which is a copy of the last file on the list ( query1-extract_ah ). ls -al should show it.