@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet


Comments:

<0> hey how would i go about geting rid of all non us-ascii chars in a file?
<0> or is sed even the right tool for the job?
<1> winkey: dos file?
<0> gnubien utf8 file and \r is us ascii
<2> tr -d '\200-\377'
<0> ok will try
<0> ty
<2> tr -cd '\0-\177'
<0> i don't understand the complement part
<2> \0-\177 is the range of ASCII (decimal 0 through 127)
<2> The complement of that set is all other characters.
<0> ahh ok
<0> can i just sub them with a space?" like tr -c '\0-\177' " "?
<0> vever used any of tr's switches before but this is very cool stuff



<0> yea that works
<0> prec thank you you saved me alot of manuyal editing
<0> and i want a finger that i didn't cut with a carpet knife
<2> If you want to remove them, just use -d
<0> gnubien just one of those days, woke up feeling like crap and barely made it though 4 1/2 hours of work
<0> went home
<1> winkey: vitamin A,D and C to the rescue ;)
<3> hi. i don't understand how sed matches newlines. I tried \n ?
<2> sed is line-based.
<2> cello_rasp: it reads one line at a time into the pattern space.
<2> cello_rasp: What is it you want to do?
<3> replace a newline prior to certain characters. I've used the regex in vim : s/\n\([a-z]\)/ \1/g
<3> i ***ume this is not possible since that requires reading the next line as well.
<2> Yes; it's possible; see the sed FAQ.
<3> thanks, i'll keep that faq. v. useful.
<3> bye
<0> how do i remove a trailing \n?
<0> once again sed is probably not the tool hu?
<2> N
<2> If you want to remove all newlines, see the FAQ.
<2> If you want to remove the last newline in the input stream? You cannot.
<2> GNU sed will preserve the lack of a newline on the last line of the input, but it will not remove it.
<4> then shell could do it, in some way. trailing (empty) newlines are removed by command substitution
<4> but i guess he means how to convert string\n to string
<0> ok i ghot around it another way
<0> i fixed it affter i changed the newlines to "' '"
<0> then sedded out the last " '"
<0> if you saw the code you would think my grasp of sed is weak
<0> and you would be right
<2> winkey: What are you trying to do, exactly?
<0> i got it now
<0> for type in $(cat gfs_d1 | cut -d "." -f 1 | uniq | grep -v -e drw) ; do echo -n "\$types['gfs']['d1']['$type'] = array(" ; echo -n $(grep gfs_d1 -e $type | cut -d "." -f 2 | tr "\n" " " | sed "s/ /', '/g") ; echo ");" ; done | sed "s/, ');$/);/"
<0> thats one of the loops there is 3
<2> gah
<0> basicly a bash script that writes some arrays in php
<0> to the tune of about 5000 lines
<2> awk -F. '$1!~/drw/&&!seen[$1]++{print$1}' gfs_d1
<0> your really loose me with awk
<2> So, what are you really doing? You want to convert the file gfs_d1 which consist of two columns to something else, right?
<2> Ah.
<4> bye
<0> http://rafb.net/p/AWavnU28.html
<0> thats without the last sed
<0> it was earlyer
<0> it works
<0> not pretty though
<2> winkey: You'll probably get better help in #bash or #awk.
<2> awk -F. '!/drw/{v[$1]=v[$1]$2" "}END{for(n in v)print n,v[n]}'
<0> its ok prec i solved 2 problems today that saved me days of work
<0> no reason to type anything into a file if you can get the computer to edit it for you ;-)
<0> now if only sed could keep the raisins from going to the bottom of the bag of cereal
<5> hi guys, i ahve a small problem, i have a list with names and i want to reaplce in a list of files a line with the names in that list , but i want to put a different name in each file



<5> i manage to fiure a way usig for but i still id did not manage, cuz i tryied to replace the text with the whole list
<5> any help ?
<5> ?
<6> I don't understand, (too tired), any clear example?
<6> archonel
<5> ?
<5> hi
<5> hi guys, i ahve a small problem, i have a list with names and i want to reaplce in a list of files a line with the names in that list , but i want to put a different name in each file
<7> archonel: calmar said : I don't understand, (too tired), any clear example? So...
<8> archonel: 'paste'
<5> ok
<5> still there ?
<5> ok... so have in a file a list of file names like 1 2 3 4 5 and i want to replace a line in a folder with files, in that line there is a file path wich will be the names i wan to replace with
<5> so the idea is to replace by pair .. so first name from file replace the line from the first file
<5> and so on
<9> can sed be used to replace a pattern with the current line number?
<9> it might be possible to do something with = but i can't see any easy way
<9> maybe = into a buffer at every line, and then replacing the pattern with the contents of the buffer?
<9> or maybe piping through nl first
<9> and using sed to extract the line number
<10> sed doesn't work with vars.
<8> use awk.
<9> i don't know awk :(
<9> i suppose i could learn
<10> Spark, it's not hard.
<10> If you sed, you're already half-way there.
<10> +know
<8> awk '/pattern/{sub(".*",NR);print}'
<8> You can do it in sed, i think you need two sed's though.
<8> I recall something like that in the grymoire tutorial.
<11> grymoire turorial is good
<12> Hi.
<4> Lo.
<12> Funny.
<12> I'll get to the point now....
<12> I am using this command: sed -e 's/<</</' 100_forum_list.html
<12> ....to remove double instances of '<<' in the named file.
<12> But it's not doing anything.
<12> Except printing the file contents.
<12> Any advice would be nice :)
<12> Thanks.
<4> sed is a stream editor
<4> sed (s)tream (ed)itor
<4> ;)
<4> mv file file.old; sed .... file.old >file; rf -f file.ol
<4> d
<12> OK. I'm a complete sed novice.
<4> when you have GNU sed, the switch -i does exactly the same for you: it renames the file, streams the file out to the old name, removes the renamed file
<12> So, you need to specify a new file to write the results to?
<12> Or they appear at <stdout> ?
<4> they come to stdout yea
<4> sed ... file >file.new
<4> or combined with the mv and rm above
<4> mv file file.old; sed ... file.old >file; rm -f file.old
<12> OK. Thanks.
<12> But, is the syntax 's/<</</' correct for replacing each instance of "<<" for "<" ?
<4> not each
<4> the first match per line
<4> you want to add the "g" (global) parameter to s///
<4> s///g
<12> I see. It's a bit like Perl really.
<4> well, guess where perl ... okay, another story ;)
<12> I know. Larry was a sed user apparently....
<12> Well, thanks for the help. I'll be going now.


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #sed
or
Go to some related logs:

forgot all passwords ubuntu
darezghost
refused mount request not exported
#linux
microperl: /lib/libc.so.6: version `GLIBC_2.3' not found microperl: /lib/libc.so
html.replace scriptaculous
#awk
bazzir
#ai
#suse



Home  |  disclaimer  |  contact  |  submit quotes