What am I doing wrong?

for filename in /home/darragh/public_html/test/*
do
 sed -i 's/..\/config/.\/config/g'
done;

It just gives me: sed: No input files

Recommended Answers

All 3 Replies

Forgetting to give the filename to sed:

for filename in /home/darragh/public_html/test/*
do
 sed -i 's/..\/config/.\/config/g' ${filename}
done;

Okay that is probably right, but now it says I don't have permission, which is right because I made those files as root, but if I do sudo for ... then it says unknown command for...

What to do know?

Run the script as root or modify your script. 'for' is just a bash command for looping what you need elevated privelages for is possibly the 'ls' and the sed:

for filename in `sudo /home/darragh/public_html/test/*`
do
 sudo sed -i 's/..\/config/.\/config/g' ${filename}
done;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.