I've been looking for a way to find-and-replace strings in all fortran files in my current directory. Most answers on here are along the lines of using:
sed -i 's/INCLUDE \'atm/params.inc\'/USE params/g' *.f
or
perl -pi -w -e 's/INCLUDE \'atm/params.inc\'/USE params/g' *.f
However, when I use either of these the bash line continuation > pops up on the next line as if it's expecting input or another argument. I haven't seen anyone else encounter this and I am not sure what to do with it. Are my commands incorrect; am I missing something?
sed -iis a non-standard extension -- the POSIX standard forseddoesn't guarantee that it'll be available, and even when it is available it may behave in different ways (the MacOS X version won't work with your given command). If you want to write portable code, consider usingexinstead, or another mechanism given as standards-compliant in the above-mentioned FAQ.'s/old-string/new-string/g', withold-stringandnew-stringas the literal, exact source and destination text (not some other text for which you're using those strings as placeholders)?sedis not part of the shell, but provided by the operating system (meaning we don't know howsed -iis supposed to behave unless we know the OS you're running, and knowing that your shell is bash vs ash or whatever has no bearing on that behavior oncesedis invoked). However, I'm theorizing that the actual source and destination strings you're using parse in a manner you don't expect by the shell, with the effect thatsedisn't actually being started -- but we can't diagnose that without those actual strings.\'isn't how you substitute a single-quote in a single-quoted string.