Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

sed: 1: "./...": invalid command code . #1

Closed
jab opened this issue Nov 9, 2009 · 4 comments
Closed

sed: 1: "./...": invalid command code . #1

jab opened this issue Nov 9, 2009 · 4 comments

Comments

@jab
Copy link

jab commented Nov 9, 2009

First off, thanks for this script, can't wait to use it once I can get it to work. For now though, when I run it I sed gives the error above many times.

I'm using Mac OS X 10.6.1 /usr/bin/sed, which doesn't seem to have a --version option, but the sed manpage has the date May 10, 2005 at the bottom as well as the following note:

 The -E, -a and -i options are non-standard FreeBSD extensions and may not be
 available on other operating systems.
@michaeljones
Copy link
Owner

Cheers for pointing that out. Might be able to get around it using a tmp file to store the processing output and then cat-ing it back into the file. I'll have a look.

@jab
Copy link
Author

jab commented Nov 10, 2009

Looks like in this version of sed, -i takes a mandatory extension argument, so that when editing files in-place, it will create backups with the specified extension. You can pass a zero-length argument however to forgo backups:

$ echo foo > test
$ sed -i "" s/foo/bar/ test
$ cat test
bar

@michaeljones
Copy link
Owner

Thanks for the additional info, it seems that for portability and speed it might be reasonable to rewrite this in Python (someone has already done it) so I might switch over to that. Save on these little issues, even though the bash implementation has a old school charm to it.

@michaeljones
Copy link
Owner

Switched to a Python implementation now.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants