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


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
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.

Code:
for i in `cat servername`;
do
ssh -q -t root@$i  sed -i '/simple_allow_groups =/s/$/, group-name1/' /etc/sssd/sssd.conf
done

Moderator's Comments:
Mod Comment Please use code tags

Last edited by jim mcnamara; 6 Days Ago at 01:16 PM..
# 2  
Just a shot in the dark: try enclosing the entire sed command in double quotes.
# 3  
I'm with Rudi. When I have problems trying something like a complex sed command over ssh because of quoting
Steps
1. make a note of my current shell - let's say it is bash
2. play with my command on one "home" box.
3. once I got it working at "home":
paste the command into a simple two line shell script, let's call it t.sh
Code:
#!/bin/bash    
[paste required external env variables here if needed]
[paste command here]

4. automate it:
Code:
for i in `cat servername`
do
   scp myusername@$i t.sh /tmp/t.sh
   ssh myusername@$i 'chmod +x /tmp/t.sh && /tmp/t.sh'
done

This looks like a lot of work. It is not. But when you execute a complex remote one-liner command it can mess up by being garbled by ssh and your command line or wrong environment variable settings. Explaining to management why your script trashed 10 servers is a whole lot more work and time consuming.
# 4  
Why scp? The script can be passed via stdin to the remote shell.
Code:
for i in `cat servername`
do
   ssh "myusername@$i" /bin/bash <t.sh
done

This User Gave Thanks to MadeInGermany For This Post:
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Sed: -e expression #1, char 16: unterminated address regex
rbadveti
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. ...... Shell Programming and Scripting
23
Shell Programming and Scripting
sed returns error "sed: -e expression #1, char 18: unterminated `s' command"
anand.shah
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 ???... Shell Programming and Scripting
8
Shell Programming and Scripting
sed: -e expression #1, char 0: no previous regular expression
InduInduIndu
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...... UNIX for Advanced & Expert Users
11
UNIX for Advanced & Expert Users
sed: -e expression #1, char 21: unterminated `s' command
avinthm
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,...... Shell Programming and Scripting
10
Shell Programming and Scripting
Using SED command in a shell script: Unterminated address regex
Alpha3363
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,...... Shell Programming and Scripting
7
Shell Programming and Scripting