+4 votes
in Operating Systems by (5.2k 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

0 votes
by (33.0k 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