problem with sed

hello there,

trying to execute this script [createABQ]


echo "input:" $1
sed -i "s/CPS3/DC2D3/g" $1

in such a way:

*sh createABQ A400X03_bwr_2_120.inp *

I get following error

input: A400X03_bwr_2_120.inp
: No such file or directory_2_120.inp
: No such file or directory
: command not found

many thanks for any help!
Alex

I copied all you did and do NOT get any problem.
So I cannot recreate the problem. Makes it difficult to help, but for you it may be a new fact.

Hope this helps a very little bit.

Edited because I’m completely stupid and did not read the question properly.

What you are doing will work.

:frowning:

I have to assume you are using bash…

“echo” prints to the console, you need “read”; e.g.


echo "Input:\c" 
read $f
sed -i "s/CPS3/DC2D3/g" $f

Cheers

No, it’s a shell script he’s running, so $1 comes from the argument to the script. And anyway, your answer is wrong, it should be:

read f

no $.

Ken,
Yes and yes. Have sort of edited my reply. A case of leaping in (again) too soon before properly reading what is clearly in front of my eyes.

Age, stupidity and beer probably contribute.

Thanks for being omniscient…

:slight_smile: