0

I have a file whose extension is .log, though I have this particular file set to open in TextWrangler instead of Console.app (using "Open with" in Finder's Get Info panel).

I have a Bash shell script (.sh) that uses SED to replace some text in a file, inline, like so:

sed -i "" "s_find_replace_g" "$FILENAME"

The problem is that after the script runs, the "Open with" association is gone; the file opens with Console.app again. Is there any way around this in the script, like setting back the appropriate metadata after the sed line?

1 Answer 1

0

It's not a "pure" Bash solution, but then, Mac metadata isn't pure Unix either. I am calling AppleScript inline:

sed -i "" "s_find_replace_g" "$FILENAME"

osascript <<-EOF
    set afile to "${FILENAME}"
    set default_app to (path to application "TextWrangler") as text
    tell application "System Events"
        set default application of disk item afile to default_app
    end tell
EOF

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .