I am trying to write a program in shell to replace strings in a text file. I'm pretty sure that my method is right, I just think I am not declaring , calling my variables correctly.
#!/bin/tcsh
#calling variables
@ replacements=0
@ i=0
set file
set string[index]
set replacement[index]
#Introduction
echo "This script will substitute a pattern with another one."
echo "How many strings will you be replacing?"
$replacements
echo "What is the path to the file you want to modify?"
$file
cp $file $file.saved
#The Meat
while ( $i<= $replacements)
echo "Enter $i pattern."
$string[$i]
echo "Enter what you want pattern $i replaced with"
$replacement[$i]
sed 's/$string[$i]/$replacement[$x]/g' $file
$i++
end
Sponsored by: █ Sparkhost - Hosting Without Compromises! █ Hybrid Performance Web Hosting █ Spark Host Stream Hosting █ Hybrid IRC & IRCd Server Shell Accounts
Simple Shell Program
Started by
Little_Dice
, Feb 20 2008 07:06 PM
1 reply to this topic
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users












