+5 votes
in Operating Systems by (9.6k points)
edited by
I want to remove the file extension from all ".txt" files in a folder. What bash command should I use to do this?

1 Answer

+1 vote
by (41.9k points)

Since you want to remove ".txt" from all text files in a folder, you can use the "mv" command with the "for" loop.

  • "cd" to the folder of those files.
  • run the following command on the terminal.
for file in $(ls *.txt);  do mv "$file" "${file%.*}" ; done
...