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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sed: -e expression #1, char 16: unterminated address regex
# 8  
Old 09-29-2016
Hi RudiC,

Thanks for the reply.

Regarding point 2 - it is just a typo error which i have corrected in this question.

The below commands when executed gives the followed result with -vx options:

Code:
 ssh -q -o "StrictHostKeyChecking no" $server_id "cd /intucell/data/logs/app; zcat $first_line_log_file | tail -1| cut -d' ' -f1-2;"

Code:
+ ssh -q -o 'StrictHostKeyChecking no' deb011 'cd /intucell/data/logs/app; zcat sample.gz | tail -1| cut -d'\'' '\'' -f1-2;'
head -1 first_line_output.txt)
head -1 first_line_output.txt
++ head -1 first_line_output.txt
+ first_log_first_line='2016-09-14 01:46:56,438'


Not working case:
Code:
 ssh -q -o "StrictHostKeyChecking no" $server_id "cd /intucell/data/logs/app; zcat $first_line_log_file | sed -rne '/$first_line_date_time/,/$first_log_first_line/p'| zgrep -A10 -i '$do_action_on_cell_2';" >> ./output.log

Code:
+ ssh -q -o 'StrictHostKeyChecking no' deb011 'cd /intucell/data/logs/app; zcat sample.gz | zgrep -A10 -i '\''Do action on cell BLA330'\'' | sed -rne '\''/2016-09-14 01:09:56,796/,/2016-09-14 01:46:56,438/p'\'''
sed: -e expression #1, char 62: unterminated address regex

Let me know in case any other information is needed.
# 9  
Old 09-29-2016
Hi,

change this to
Code:
sed -rne '/$first_line_date_time/,/$first_log_first_line/p'

double quotes. (as per post#1 these are variables)
Code:
sed -rne "/$first_line_date_time/,/$first_log_first_line/p"

# 10  
Old 09-29-2016
There's no 62 chars in that regex; try setting the -vx options on the remote node, e.g. just before cd in the ssh command...
# 11  
Old 09-29-2016
As per greet_sed changed sed expression to double quotes and output is below - NOK
Change is observed in the time stamp - space is highlighted:

Code:
 + ssh -q -o 'StrictHostKeyChecking no' deb011 'cd /intucell/data/logs/app; zcat sample.gz | sed -rne /2016-09-14' '01:09:56,796/,/2016-09-14' '01:46:56,438/p | grep -A10 -i '\''Do action on cell BLA330'\'';'
sed: -e expression #1, char 16: unterminated address regex

As per RudiC, added -vx before "cd in the code and below is the output:

Code:
 ssh -q -o "StrictHostKeyChecking no" $server_id -vx "cd /intucell/data/logs/app; zcat $first_line_log_file | sed -rne '/$first_line_date_time/,/$first_log_first_line/p' | grep -A10 -i '$do_action_on_cell_2';"

Output as below:
Code:
 + ssh -q -o 'StrictHostKeyChecking no' deb011 -vx 'cd /intucell/data/logs/app; sample.gz | sed -rne '\''/2016-09-14 01:09:56,796/,/2016-09-14 01:46:56,438/p'\'' | grep -A10 -i '\''Do action on cell BLA330'\'';'
OpenSSH_6.0p1 Debian-4+deb7u2, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to deb011 [x.x.x.x] port 22.
debug1: Connection established.
...
...
debug1: Sending command: cd /intucell/data/logs/app; zcat sample.gz | sed -rne '/\033[36m2016-09-14 01:09:56,796/,/\033[32m2016-09-14 01:46:56,438/p' | grep -A10 -i 'Do action on cell BLA330';
sed: -e expression #1, char 62: unterminated address regex
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 2888, received 2000 bytes, in 0.0 seconds
Bytes per second: sent 270866.5, received 187580.7
debug1: Exit status 1

From the output above, i feel the below part is suspicious:
Code:
 '/\033[36m2016-09-14 01:09:56,796/,/\033[32m2016-09-14 01:46:56,438/p'

Kindly guide
# 12  
Old 09-29-2016
You have "ECMA-48 Set Graphics Rendition" control codes in your variable definition - that's how the 62 char is reached. I think, sed complains about opening but no closing square brackets.
# 13  
Old 09-29-2016
Great, so any clue on how do i get out of this ?
# 14  
Old 09-29-2016
Remove the control codes when/before assigning the variables.
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

Unterminated Regular Expression

It is ok when I send send one arguement to $TILL in the awk expression. first(){ TILL=$1 echo $TILL awk '/:\\/ {P=0} P {print $0 "<br>"} FNR==1{printf("File %s:<br>", FILENAME)} /'$TILL'\/ {P=1} ' ${dirlist } } echo "<table border = '1'>" echo '<tr><td> </td><td>' ;... (3 Replies)
Discussion started by: alvinoo
3 Replies

3. Shell Programming and Scripting

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

Greetings.. getting the error while execution of the script, correct where i am missing #!/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}'`... (7 Replies)
Discussion started by: manju98458
7 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 With Regex to extract Email Address

Hi Folks, In my program, I have a variable which consists of multiple lines. i need to use each line as an input. My intention is to extract the email address of the user in each line and use it to process further. The email address could be anywhere in the whole line. But there will be only... (5 Replies)
Discussion started by: ragz_82
5 Replies

7. 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

8. Shell Programming and Scripting

sed unterminated `s' command?

Hi there, I'm pretty new to this whole scripting thing. I've written myself something which takes my txt file of SMSes (the backup from the phone), and puts them into an email format, saving them as .eml files. I've tested and uploaded a batch to gmail, but because of threading issues, I've... (1 Reply)
Discussion started by: donnacha
1 Replies

9. Shell Programming and Scripting

Using SED command in a shell script: Unterminated address regex

Hi All, I am trying to use a sed command in a shell script in order to delete some lines in a file and I got the following error message. I don't understand why it is not working 'cause I have tried with simple quotes, then with double-quotes, and it is not working. sed: -e expression #1,... (7 Replies)
Discussion started by: Alpha3363
7 Replies

10. Shell Programming and Scripting

Regex/sed - matching any char,space,underscore between : and /

trying to remove the portion in red: Data: mds_ar/bin/uedw92wp.ksh: $AI_SQL/wkly.sql mds_ar/bin/uedw92wp.ksh: $EDW_TMP/wkly.sql output to be: mds_ar/bin/uedw92wp.ksh: wkly.sql mds_ar/bin/uedw92wp.ksh: wkly.sql SED i'm trying to use: sed 's/:+\//: /g' input_file.dat >... (11 Replies)
Discussion started by: danmauer
11 Replies
Login or Register to Ask a Question