Link to home
Start Free TrialLog in
Avatar of btocakci
btocakciFlag for Türkiye

asked on

extension changing

hi!i need to write a shell script which changes the extensions of files in a directory.
For example, if the name of the script is ext.sh then a call such as below
ext.sh c cpp
changes the extensions of files which are "c" to "cpp"..

Need your help, thanks..
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Heem14
Heem14

FWIW, you can do this without a script as well


rename .c .cpp *.c

or for another example

rename .txt .text *.txt

Avatar of btocakci

ASKER

hi sunnycoder!
which variable is c and which one is cpp??
how can adapt your command as i want? (c to cpp)
>ext.sh c cpp
>changes the extensions of files which are "c" to "cpp"..
$1 is the first argument ... c in your example ... $2 is the second argument ... cpp in your example