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.

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

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
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
[paste required external env variables here if needed]
[paste command here]

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

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.
for i in `cat servername`
   ssh "myusername@$i" /bin/bash <

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
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
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 ???... Shell Programming and Scripting
Shell Programming and Scripting
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...... UNIX for Advanced & Expert Users
UNIX for Advanced & Expert Users
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,...... Shell Programming and Scripting
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,...... Shell Programming and Scripting
Shell Programming and Scripting