Sed: -e expression #1, char 2: extra characters after command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sed: -e expression #1, char 2: extra characters after command
# 1  
Old 11-19-2012
Sed: -e expression #1, char 2: extra characters after command

Greetings..

getting the error while execution of the script, correct where i am missing
Code:
 
#!/bin/bash
DATE=`date +%Y-%m-%d:::%H:%M`
HOSTNAME=`hostname`
TXT="/log/temp.txt"
LOGPATH="/log1/commanlogs/"
IP=`/sbin/ifconfig | grep -i inet| head -n1| awk '{print $2}'| awk -F : '{print $2}'`
#To Check HTTP Instance
for di in abc abcd ;
do
ps -ef | grep $di | grep -v grep | grep root > /dev/null
if [ "$?" -ne "0" ]; then
count= grep $di $TXT | wc -l
if [ count -ne 0 ]; then
continue;
fi
echo $di >> temp.txt
DU=DOWN
D1=`date +%H-%M-%S`
LOG="$LOGPATH$HOSTNAME-$D1-HTTP-$di-Instance-Down"
echo "DATE $DATE" > $LOG
echo "IPADD $IP" >> $LOG
echo "HOSTNAME $HOSTNAME" >> $LOG
echo "STATUS $di is $DU" >> $LOG
echo "MSG $di-Instance" >> $LOG
echo "TV NONE" >> $LOG
else
sed -i "$di" $TXT
fi
done

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by vbe; 11-19-2012 at 11:39 AM..
# 2  
Old 11-19-2012
Corrections:-
Code:
count=$( grep $di $TXT | wc -l )

Code:
if [ $count -ne 0 ]; then

# 3  
Old 11-19-2012
still It's not working
# 4  
Old 11-19-2012
Please be more specific, what error message are you getting?
# 5  
Old 11-19-2012
Main goal of the scipt is to execute alert only one time in hour when https

services is down. below is the error when i execute the script with sh -x

script

sed: -e expression #1, char 2: extra characters after command
# 6  
Old 11-19-2012
Tested your script with corrections I suggested, works fine for me! Set the debug and check:-
Code:
#!/bin/bash -xv

# 7  
Old 11-19-2012
what's the objective of this?
Code:
sed -i "$di" $TXT

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sed: -e expression #1, char 20: unterminated address regex

I am trying to add word in last of particular line. the same command syntex is running on prompt. but in bash script give error."sed: -e expression #1, char 20: unterminated address regex" Please help. for i in `cat servername`; do ssh -q -t root@$i sed -i '/simple_allow_groups =/s/$/,... (4 Replies)
Discussion started by: yash_message
4 Replies

2. Shell Programming and Scripting

Sed: -e expression #1, char 16: unterminated address regex

I am trying to grep for a particular text (Do action on cell BL330) in a text file(sample.gz) which is searched in the content filtered by date+timestamp (2016-09-14 01:09:56,796 to 2016-09-15 04:10:29,719) on a remote machine and finally write the output into a output file on a local machine. ... (23 Replies)
Discussion started by: rbadveti
23 Replies

3. Shell Programming and Scripting

How does this sed expression to remove non-alpha characters work?

Hello! I know that this expression gets rid of non-alphanumeric characters: sed 's///g' and I understand that it is replacing them with nothing - hence the '//'-, but I don't understand how it's doing it. It seems it's finding strings that begin with alphanumeric and replacing them with... (2 Replies)
Discussion started by: bgnersoon2be#1
2 Replies

4. Shell Programming and Scripting

sed returns error "sed: -e expression #1, char 18: unterminated `s' command"

Hello All, I have something like below LDC100/rel/prod/libinactrl.a LAA2000/rel/prod/libinactrl.a I want to remove till first forward slash that is outputshould be as below rel/prod/libinactrl.a rel/prod/libinactrl.a How can I do that ??? (8 Replies)
Discussion started by: anand.shah
8 Replies

5. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies

6. Shell Programming and Scripting

sed: -e expression #1, char 21: unterminated `s' command

I have read many threads, but I still didn't find the right answer. May be i didn't find the right thread, though are so many threads for the same question. Basically the situation is - find date in a file and replace it with another date. (its not homework, its part of lot of a big processing,... (10 Replies)
Discussion started by: avinthm
10 Replies

7. Shell Programming and Scripting

'sed' command shows extra line

Here is an interesting problem that I am seeing when using 'sed'. The goal is to print out the names of the Oracle SID's on a system and here is the command I am using: ps -ef|grep ora|grep pmon|awk '{print $NF}'|sed 's/ora_pmon_//' The output of the command after the awk is this: ... (3 Replies)
Discussion started by: soleil4716
3 Replies

8. Shell Programming and Scripting

Extra control characters being added when I create a file using cat command

Hi, I am using Cygwin.I created a new file and type into it using cat > newfile. When I open this using vi editor, it contains loads of extra control characters. Whats happening? (1 Reply)
Discussion started by: erora
1 Replies

9. Shell Programming and Scripting

Sed replace characters not equal to an expression

Hi all, Suppose I have a file with the contents below, and I only want to print words %S_ then | sort -u. ------------------------------ The %S_MSG that starts with '%.*s' is too long. Maximum length is %d. The %S_MSG name '%.*s' contains more than the maximum number of prefixes. The... (5 Replies)
Discussion started by: poldo
5 Replies

10. Shell Programming and Scripting

How to eliminate extra char?

I was trying to grep a variable with one space in my file: questionlabel=Q1 more job.tex Q1 pear Q1A applie grep -i "$questionlabel\ " job.tex > tmp But I keep getting : Q1 and Q1A both in my tmp Thanks!!!! (4 Replies)
Discussion started by: whatisthis
4 Replies
Login or Register to Ask a Question