Confused with sed...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Confused with sed...
# 1  
Old 03-26-2012
Confused with sed...

Yes I know this is a bad use of cat, but just ignore it please :P
My problem is with sed.

File: "newFile" contains:
day

Command I run:
cat newFile | sed 's/day/night'

This returns:
sed: -e expression #1, char 11: unterminated `s' command

Why???
# 2  
Old 03-26-2012
Hi maximus73,

Because substitute command has three slashes, to separate the regex part, the replacement string and flags.

It should be:
Code:
$ cat newFile | sed 's/day/night/'

This User Gave Thanks to birei For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Confused by the sed command

Hi Gurus, I am a little bit confused by the sed command. my file is below cat sample aaa bbb ccc ddd eee fff ggg hhh iii below is command and output. (6 Replies)
Discussion started by: ken6503
6 Replies

2. Shell Programming and Scripting

SED - confused by the s command.

echo "abc 123" | sed 's/*/& &/g' output: a b c 123 123 Why there are spaces between the "abc" letters? echo "abc 123" | sed 's/*/&&/' output: abc 123 Why the regex in the above script does not match anything? I thought * should match 123 in any case. ---------- Post updated at 08:25... (3 Replies)
Discussion started by: kevintse
3 Replies

3. Ubuntu

New and Confused

Hello, I am having a problem with Dual Booting Windows XP Pro and Linux Mint. I have Three Hard Drives, One Hard Drive has Linux Mint Loaded on it. When it is hooked up to the computer by itself it works great. This is an IDE Drive. The Second Hard Drive has Window XP Pro loaded on it.... (3 Replies)
Discussion started by: Forextrading
3 Replies

4. Solaris

Confused c#t#d#s#

I am confused c#t#d#s# once I learn the following : slice 0 ...... 0 to 2520 slice 1....... 2521 to 2840 slice 6........2841 to 8891 slice 2........0 to 8891 really really confused. Please explain. (8 Replies)
Discussion started by: deltakutty
8 Replies

5. Shell Programming and Scripting

sed very confused

Hello experts, I have this complicated code that output value in between pattern and add "a string" to the front of the output. The problems I have many pattern that are the same. so I want to know how to get the value between 1st pattern, 2nd pattern etc. Any suggestions? sed -n... (14 Replies)
Discussion started by: minifish
14 Replies

6. Shell Programming and Scripting

confused with cp

may i know what cp $1 $2 $0 $2 does? (12 Replies)
Discussion started by: C|[anti-trust]
12 Replies

7. UNIX for Dummies Questions & Answers

confused

hi! how when i'm chattin inside com there was this chatter andi don't know what he did but he saw all my files inside my shell. what did he do? (4 Replies)
Discussion started by: hapiworm
4 Replies

8. UNIX for Dummies Questions & Answers

confused,,,,

Hi,,, is there any possibility to install Linux in my P.C which is use Win98 without loose anything from my hard disk???? ---------------------------------------------------------------------------------- Is it better for a newbie in this kind of OS to install Linux instead of... (5 Replies)
Discussion started by: spyros
5 Replies
Login or Register to Ask a Question