Q. One of the blog follower asked this question. Write a LINUX shell script that accepts an arbitrarily long list of file names as arguments and replaces all digit’s in them with a “*”.

This is bit tricky and the solution I got is below script

#!/bin/bash
for i in $(ls | grep ‘[0-9]’)
do
eval mv $i $(echo $i | sed ‘s/[0-9]/*/g’)
done

Some of the issues I faced are
1)In sed I tried to replace numbers with just * which created an issue
2)In sed I tried to replace numbers with * which is still not working.

So I tried to use eval to get this solution. I advantage of eval is that it will try to evaluate a shell code on the fly.
ls | grep [0-9] will give you the files which contain a single number in it’s filename, this output is feed in to for loop and each value is read in to i variable.

sed ‘s/[0-9]/*/g’ Will search for a number in the filename and replace it with *.
eval command will convert mv $filename $(echo $i | sed ‘s/[0-9]/*/g’) to mv file1name file*name

Hope this helps.