@# Quotes DB     useful, funny, interesting





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


Comments:

<0> Is this insane? print t[split($NF,t,"_")] - print after the last underscore of the last field
<1> insane in what way
<1> its cute
<1> though it ***umes split will always succeed.
<0> Hmm, true.
<0> I was just wondering if I'd missed anything.
<1> seems idiomatic to me.
<2> hi there
<2> i am trying to call awk and set a variable RS=/[\n \.,<>;:?!]/
<2> but if i use option
<2> -v RS=/[\n \.,<>;:?!]/
<2> or
<2> -v "RS=/[\n \.,<>;:?!]/"
<2> bash interprets something in that expression and gives error msg



<3> mnvl, see "quoting" of your "man $SHELL"
<2> if you mean i should do
<2> -v 'RS=...'
<2> that doesn't work either
<2> but for a different reason - awk seems to return the whole file, instead of matching what i asked for
<4> maybe RS='[\n \.,<>;:?!]'
<2> no
<4> maybe RS='[:punct:]'
<2> cool
<2> punctuation is good but i want whitespace, < and > as well
<2> it would be cool if someone could just suggest why the whole file is being matched
<4> maybe RS='[[:blank:][:space:][:punct:]]'
<2> i don;t know where you are getting this from
<2> [:punct:] seems to match what you would think: p, u, n c, t, or :
<4> character cl***es in pcre iirc like RS='[[:punct:]]'
<3> mnvl, are you sure what you try to do is possible at all? RTFM "RS" again, at least over here it takes only 1 char.
<2> well thanx for your enormous help Rado
<2> i figured out myself it wasn't a bash quoting prob
<4> mnvl: what works? post it here
<2> i didn't fix it yet
<2> but i realized it is treating the RS line in some weird way that matches the whole file
<2> and then ignoring the actual patterm
<3> mnvl, you misunderstood me: RS doesn't take patterns, just single chars.
<3> "The first character of the string value of RS is the input record separator; a newline character by default."
<2> yes that was my msitake trying to use a regexp
<2> FS does not take regexps either, just a single string
<2> i suppose it is possible to use whitespace as a seperator, and change the pattern to something that matches the original pattern pre- or postfixed by punctuation or a html tag..
<2> or just use perl
<0> If RS is any single
<0> character, that character separates records. Otherwise,
<0> RS is a regular expression. Text in the input that
<0> matches this regular expression separates the record.
<0> gawk
<2> i don;t have gawk i have mawk
<0> Yeah - I gathered.
<0> I was just pointing out that it'll work like you expect in some awks.
<0> It can be really handy - RS="[\r\n\\+" for example.
<0> splitjpg:awk -v RS='' '//{print ""$0 >>NR}' $@
<0> Is a silly example :)
<2> a silly unicode example too, i'm afraid
<3> mnvl, GaimEvil, basically keep in mind to "rtfm" of the tool you use and not what others tell you works. :)
<0> Actually not.
<0> Not unicode that is.
<2> oh, well i couldn't read it
<0> It's the four header bytes from a jpeg
<2> oh ok, sorry
<0> Err- three
<2> i get it now
<0> To split a file containing concatenated jpegs
<2> well, i can split into fields using a regexp, but i can't print the field that matches; only the whole record
<0> march()
<0> Err match()
<0> match($0,"foo*bar");print substr($0,RSTART,RLENGTH)



<0> or something
<2> Rado, talking of 'rtfm' why don;t you 'stfu' ?
<3> Because you could have figured it out if you had rtfm rather than to rely on other people's tools so there advice doesn't apply to you.
<3> there->their
<2> what other people's tools?
<2> what are you tlking about?
<3> Does yours allows regexp for RS or not?
<3> -s
<2> Rado, if i was still reading the 'bash quoting' manual i would never have spotted the elementary mistake i made and which you failed to spot when you 'advised' me
<2> in future if you are just as clueless as the person asking the q, why don't you just keep quiet??
<3> Which "elementary mistake" do you mean?
<2> RS taking a single character
<0> Bash quoting in the manpage ****s - in a way - it doesn't mention !
<3> Why do you blame me for your mistake? How could I know you haven't rtfm already?
<0> Until a seperate section
<3> rtfm first, then come here.
<2> in future if you are just as clueless as the person asking the q, why don't you just keep quiet??
<3> mnvl, prove 1st that I'm as clueless as you are.
<2> GaimEvil, your 'match' example is not right either because it will print only the match, rather than the whole record containing the match
<0> Ah - I misunderstood.
<0> Could you clarify exactly what you want to do?
<2> sure
<2> i want to read in a html file, and then print out all the 'words' which match my pattern
<2> where words are separated not only by whitespace, but also punctuation or < and > (from html tags)
<2> ie from the string "RE:GaimEvil</br>"
<2> if the pattern is *vil, i want the output to be "GaimEvil"
<0> Do you care about preserving the document condition?
<0> tr 'whatever'
<0> '\n' file.html|awk '/vil/'
<2> what do you mean?
<0> I mean use tr - or some other program to change all the chars you want as seperators, to newlines.
<2> right, first divide everything into words
<2> then can even just use grep
<0> Or use the field seperator.
<0> and check each field in turn
<0> Or just use gawk.
<2> i thought of that approach, but i figured that awk would be able to do it
<2> without putting together different tools using pipes
<0> It can - it's just less convenient in some variant.s
<2> right now i am writing a loop which goes through each field of each record to match and print
<2> should also work, i guess..
<0> As long as your awk handes very long lines
<2> yes, it worked
<2> cool
<2> i may try the other way too though
<2> thx a lot for you time
<5> awk '{print length,$0|"sort"}'
<5> Anyway to get that to print $2
<5> without piping to another instance of awk?
<0> what do you want to do?
<5> print words in order of length
<5> shortest -> longest
<0> In every line?
<5> one word per line
<0> You mean that the input is one word per line?
<5> input is a file, one word per line.
<0> Trivial way
<0> awk '{a[$0]=length}
<0> END{for(x=100;x=1;x--)for(y in a){if(a[y]
<0> oops - gtg
<0> anyway - iterate over the array -
<5> hehe
<5> I had thought of that, but it has to be done in less than 40 chars :)
<5> thanks
<0> If you can use pipes - then just awk '{print length,$0}'|sort -nk1|awk '$0=$2'


Name:

Comments:

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






Return to #awk
or
Go to some related logs:

Procedure in php4
#linux
#math
#perl
kde welan
#lisp
#perl
hezardastan
mysql+reindex+autoincrement
/tmp/mysql.sock onto ubuntu



Home  |  disclaimer  |  contact  |  submit quotes