#!/bin/bash
#
# Replaces blanks with underscores in all the filenames
# of the current directory.
i=0
for filename in *
do
echo "$filename" | grep -q " "
if [ $? -eq 0 ]
then
fname=$filename
n=`echo $fname | sed -e "s/ /_/g"`
mv "$fname" "$n"
((i++1))
fi
done
Well that is my question. Why are you fixated on expr? Being so fixated on expr tells me that this is some kind of homework assignment where you expect someone to just give you the answer. Well, the closest I am going to come is to tell you that there is a tutorial at the top of the shell scripting forum, it may, then again it may not, cover expr. Then, there is always google.