sed error unterminated `s' command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers sed error unterminated `s' command
# 1  
Old 03-22-2012
sed error unterminated `s' command

I have list of data I have cut down to format:
Code:
[28/Feb/2007
[27/Feb/2007
... etc etc

I am using sed command to remove the [

sed 's/[//'
Returns error:
Code:
sed: -e expression #1, char 5: unterminated `s' command

Full code line is:
Code:
cat textFile | cut -d ' ' -f 4 | cut ':' -f 1 | sed 's/[//' | less

Thanks,

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


Okay thanks

Last edited by maximus73; 03-22-2012 at 12:39 PM.. Reason: iCode
# 2  
Old 03-22-2012
That is a useless use of cat.

The [ character is special to sed, to match a real [ you have to escape it like \[

To just delete a simple character though, you don't need sed at all:

Code:
<filename cut -d ' ' -f 4 | cut ':' -f 1 | tr -d '[' | less

All of this could probably be done with awk in one step, too, if we had more details.
# 3  
Old 03-22-2012
Thank you,
 
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

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies

4. Shell Programming and Scripting

Error in sed command

Hi, I am trying to run below script where my input file contains URL 1:Port1 URL 2:Port2 URL 3:Port3 IFS=" " #Loop through the file HSFILE=/home/Temp/Components.txt for line in $HSFILE ;do Url=$(awk -F":" '{print $1}' $HSFILE) Port=$(awk -F":" '{print $2}' $HSFILE) echo... (3 Replies)
Discussion started by: sharsour
3 Replies

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

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

[Solved] sed - query - unterminated suddenly

Hi, I have been trying to get various sed statements to work. I thought I had cracked it when suddenly I start recieving these messages "sed: -e expression #1, char 14: unterminated 's' command" It happens on any sed statement I now run. The only thing I have done inbetween trying to get... (0 Replies)
Discussion started by: mcclunyboy
0 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

Syntax error: Unterminated quoted string

I keep having problems when exicuting this file. It always gives me the error message "36: Syntax error: Unterminated quoted string" If someone could help me edit this it would be much appreciated. #!/bin/sh # # This will continue adding numbers # untill the total is greater than 1,000 #... (5 Replies)
Discussion started by: evilSerph
5 Replies
Login or Register to Ask a Question