Another unterminated ‘s’ command Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Another unterminated ‘s’ command without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I am trying to make a simple replacement for an IPv4 address script.

sed "s/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/192.100.100.100/g"

This is what I have. As stated in the title I am receiving an unterminated ‘s’ command.

Edit: I am running on Windows,connecting to a Unix machine through ssh.

I originally had:

 sed 's/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/192.100.100.100/g'

But I changed it from single quotes to double quotes because something may have not being read as intended and that may have been causing my error. I tested it and still the results remained the same “unterminated ‘s’ command”.

Any ideas or advice would be great!

Entire Script

#!/bin/sed -f

#sed 's/[^@ ]*@[^@]*.[^@ ]*.[^@]*/account@example.com/g'

#sed 's/[^@]*.[^@]*.[^@]*/example.com/g'

sed "s/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/192.100.100.100/g"

Example File Input:

From: Mail System Internal Data <example@a.b.c>
Subject: DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA
X-IMAP: 1322061792 0000000000
Status: RO

Email message goes here.

From example@a.b.c Tue Nov 22 15:24:01 2011 -0500
Status: R
X-Status:
X-Keywords:
Return-Path: <spam.spam.a@b.c>
X-Original-To: example@a.b.c
Delivered-To: example@a.b.c

Answer

Your script is a sed script, not a shell script. So you don’t need to put sed at the beginning of the line, or put quotes around the commands. Change it to:

#!/bin/sed -f

s/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/192.100.100.100/g
We are here to answer your question about Another unterminated ‘s’ command - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji