Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

using sed

Name: Anonymous 2010-06-03 20:08

I'm trying to use sed to append "/0.0.0.0" to the end of each line in a file

sed -i 's;$;/0.0.0.0;g' file.txt

problem is most of the time, "/0.0.0.0" is made as a new line after the existing ones, instead of being appended to the ends of the lines

so instead of:
text/0.0.0.0

I get:
text
/0.0.0.0

Name: Anonymous 2010-06-03 20:17

Sucks to be you.

Name: Anonymous 2010-06-03 20:26

>>2
ಠ_ಠ

Name: Anonymous 2010-06-03 20:34

COPY IT BEFORE THE END LINE CHAR!

Name: Anonymous 2010-06-03 20:35

This solve your problem? *untested*
sed 's/\(.*\)/\10.0.0.0/' file.txt

Name: Anonymous 2010-06-03 20:41

>>3
What did you expect? If you want an answer, ask a question.
It helps if the question demonstrates that you've read the relevant documentation before coming here. Which you haven't.

Name: Anonymous 2010-06-03 20:42

>>5
Same problem, except that doesn't write the forward slashes either

Name: Anonymous 2010-06-03 20:46

>>6
What did you expect? If you want an answer, ask a question.
Don't be obtuse, it's obvious what I wanted to do.

It helps if the question demonstrates that you've read the relevant documentation before coming here. Which you haven't.
Actually finding relevant documentation for sed is like the fucking lottery.

Name: Anonymous 2010-06-03 20:51

>>7
oh right, misread the question sed 's/\(.*\)/\1\n\/0.0.0.0/' foo
or the slightly more readable sed 's_\(.*\)_\1\n/0.0.0.0_' file.txt

Name: Anonymous 2010-06-03 20:54

>>8
What, I found http://www.grymoire.com/Unix/Sed.html to be really helpful when figuring out sed. It's the top hit on google and even has a section titled 'using newlines in sed scripts'

Name: Anonymous 2010-06-03 21:00

>>9
thanks, but that puts it on a new line
I'm trying to append it to the end of each line, and for some reason ending up with it on new lines most of the time

Name: Anonymous 2010-06-03 21:04

>>11
I thought you wanted it on the newline, in that case just leave out the '\n'.

Name: Anonymous 2010-06-03 21:05

>>10
I've seen that site
I've implemented several different variations of appending things to the end of lines (including putting a backslash behind the forward slash)
I still keep getting new lines even though I'm not specifying that.

Name: Anonymous 2010-06-03 21:06

>>12
tried that too, it still ends up on a new line

Name: Anonymous 2010-06-03 21:09

This is the file I'm trying to work with:
http://sites.google.com/site/rhershje5s/hosts.txt

It's an ad-blocking hosts file I'm trying to write a script to change into Dnsmasq form for my router.

Name: Anonymous 2010-06-03 21:13

>>15
I could easily change it in notepad or something, but I'd like to automate it so that it can update the list itself every so often.

Name: Anonymous 2010-06-03 21:17

>>13
The problem is you.

Name: Anonymous 2010-06-03 21:20

>>17
And next you'll say you could do it in your sleep, and yet instead of posting the solution you're going around making ad-hominem attacks.

Name: Anonymous 2010-06-03 21:36

>>18
Exactly. Read SICP.

Name: Anonymous 2010-06-03 21:54

>>18
* Your

Name: Anonymous 2010-06-03 23:01

>>18
Why should we encourage your laziness and incompetence, exactly? Interesting problems are one thing (and the reason /prog/ exists), but this is just reading the fucking documentation.

Name: Anonymous 2010-06-04 3:17

>>20
0/10

>>21
The documentation that is available doesn't say anything about this issue

Name: Anonymous 2010-06-04 3:45

How odd that none of the would-be help himmers have understood the issue, nor read the documentation themselves.  This must be a symptom of the common culture of mediocrity you all subscribe to.  I'm tempted to give you a hint, but honestly, I hope you never solve it.

Name: Anonymous 2010-06-04 3:56

>>23
You don't actually know, do you?

Name: Anonymous 2010-06-04 4:01

>>24
Of course I do.  What fool cannot see such a simple flaw?

Name: Anonymous 2010-06-04 4:03

>>25
you, obviously.

Name: Anonymous 2010-06-04 4:19

>>26
Oh, silly /prog/lodyte.  Why must you project your inadequacy onto others?  It's really quite shameful.

You know, there was a time when /prog/ was inhabited by actual expert programmers.  Now it seems we let in the average five-year-old who believes that answers only come from some mystical place beyond the stars.  Who accuse geniuses of ``not knowing'' that which a mere second's deduction would reveal.  Very, very shameful.

Name: Anonymous 2010-06-04 4:29

>>27
Oh, silly /prog/lodyte.  Why must you project your inadequacy onto others?
That's what you're doing

Now it seems they let in the average five-year-old like myself who believes that answers only come from some mystical place beyond the stars.
fixed.

If you don't know how to do something, you can just say so.
Acting like you do so you can feel better about yourself is just immature.

Name: Anonymous 2010-06-04 4:42

>>23
I just took the time to actually read about OP's problem and I realize that it's a trivially simple case of enabling one option. Cheers.
>>24,26
This only works in cartoons, silly.

Name: Anonymous 2010-06-04 4:50

>>29
>>27
samefag, also see
If you don't know how to do something, you can just say so.
Acting like you do so you can feel better about yourself is just immature.

Name: Anonymous 2010-06-04 5:04

knowledge/ignorance is not the same as intellect

The reason good programmers are dwindling in numbers is because nobody bothers to actually teach anybody anything.

There are plenty of people who could become good programmers if the knowledge were actually available to them.

Name: Anonymous 2010-06-04 5:17

>>31
Right. Blame teachers, as opposed to the laziness of students who don't want to think for themselves but expect everything to be handed to them on a silver platter.

Name: Anonymous 2010-06-04 5:24

>>32
Right. Blame teachers
Would you understand Relativity if nobody ever explained it or wrote much about it?

Name: Anonymous 2010-06-04 5:24

You could simply use perl -e.

Name: Anonymous 2010-06-04 5:33

>>28
I dont know how to do something.
Now what?

Name: Anonymous 2010-06-04 5:56

>>33
I read Einstein's On Relativity and understood it. I'm sorry if you need someone to give you Head First Relativity and hold your hand through a four-semester course on enterprise relativity theory.
Your analogy is broken, anyway, because the documentation is there and it's great.

Name: Anonymous 2010-06-04 6:09

>>36
I read Einstein's On Relativity
Now suppose he only wrote a fraction of the information that's in it, and told everyone else "figure it out yourself"

Name: Anonymous 2010-06-04 6:14

>>35
Go read some documentation that's not very comprehensive and magically just know how to do everything including what isn't covered.

Name: Anonymous 2010-06-04 6:23

>>38
are you saying the fucking source code for fucking sed isn't available anywhere?

Name: Anonymous 2010-06-04 6:52

>>39
because source code = documentation

Name: Anonymous 2010-06-04 6:55

>>40
In well-written tools, yes. That and info.

Name: Anonymous 2010-06-04 6:59

's_\(.*\).$_\1/0.0.0.0_'

Name: Anonymous 2010-06-04 7:02

Hello, My name is XARN and I'm an expert user of full-width characters

Name: Anonymous 2010-06-04 7:04

>>40
there's a book called SICP. read it.

Name: Anonymous 2010-06-04 7:18

????????????????????, ???????? ???????????????? ???????? ???????????????????????? ???????????? ????????????????

Name: Anonymous 2010-06-04 7:59

Hilarious.

Name: Anonymous 2010-06-04 10:24

>>37
Your analogy is broken, anyway, because the documentation is there and it's great.

>>43
Forgot full-width spaces.

Name: Anonymous 2010-06-04 14:06

>>45
What in the penis lickers! This text shows up as all blocks for me.

Name: Anonymous 2010-06-04 14:28

>>48
Install Linux then.

Don't change these.
Name: Email:
Entire Thread Thread List