I've written a small script to replace certain words in all the the files in a directory.
Code:
#!/bin/sh
#Get list of files to be edited
file_list=`ls -p`
for i in $file_list
do
echo "Processing $i"
alteredi=`echo "$i" | sed -e 's/\//d/'`
if [ $i = $alteredi ]
then
if [ $i != "maketest" ]
then
#actual altering
cat $i | sed -e "s/login\//login.tst\//" > $i
cat $i | sed -e "s/cyberkd\//cyberkd.tst\//" > $i
cat $i | sed -e "s/\/db_connect.inc.php/\/testdb_connect.inc.php/" > $i
echo " $i has been altered"
else
echo " Not altering myself"
fi
else
echo " Not altering directories"
fi
done
Now, when I run this script as a normal user, only the first 4kB of the file is processed. So all files larger than 4kB are cut in half. The remaining bytes are just left out of the new file. When I ran the script as root, 8kB were processed. Is there a way to process the entire files?
When I cat a large text file the entire file gets printed on my screen.
Thanks in advance.