Amdocs interview question

How to rename a set of *.txt files to *.c

Interview Answers

Anonymous

14 Mar 2010

mv cant be used because it will try to find a file with name *.c. So need to use for loop kind of thing. for example: 1)for i in `find / -type f -name '*.txt' -print` do x=`cut -d'.' -f1` mv $i $x.c done 2) ls *.txt|sed -e 's/.*/mv & &/' -e 's/.txt/.c/2'|sh

2

Anonymous

25 Mar 2016

All of above command may seems good to all of you, but except rename command follow command is more compatible to do such task: find / -name "*.txt" -exec mv {} {}.c \;

1

Anonymous

5 Jun 2017

By using alias name = sai

Anonymous

25 May 2020

gff

Anonymous

28 Feb 2015

Use command 'basename'

Anonymous

13 Jul 2012

rename 's/\.txt/\.c/' *.txt

3