How to rename all the files in a folder having specific
extension?
Example: I have some files with extension (.txt) in a folder
name 'Test'. I have to rename all the .txt files in a test
and its subdirectories to .my extension.
Answer Posted / geichel
#!/bin/bash
for x in $(find $1 -name '*.txt' -type f )
do
OUT=$(echo $x | sed -e "s/\.txt$/.my/")
mv $x $OUT
done
exit 0;
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Can shell script run on windows?
What command needs to be used to take the backup?
What is the difference between break and continue commands?
What is bash coding?
I want to monitor a continuously updating log file, what command can be used to most efficiently achieve this?
Explain about the slow execution speed of shells?
How to print pid of the current shell?
Using set -A write a script to print the output of the ls command in 5 columns with two spaces between each column. Pretend that ls does not have multicolumn output.
Explain about echo command?
How to write a function?
What is bash shell command?
How to replace following lines, catch (DAOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } catch (BOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw e; } catch (Exception e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } Needs to be changed in to, catch (DAOException e) { AppException.handleException (null, null, e, null, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); } catch (BOException e) { AppException.handleException (null, null, null, e, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 0); } catch (Exception e) { AppException.handleException (null, null, null, null, null, e, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); }
What is the command to find out today's date?
What is shell geeksforgeeks?
How can I send a mail with a compressed file as an attachment?