@# Quotes DB     useful, funny, interesting





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


Comments:

<0> xmb: syn
<0> if i have a file containing a series of lines, and I want to print out only the lines where the first field matches the first field of the subsequent line how should I do that?
<0> ie something like : awk -F- '{if( $1 ~ $1 ){print $0}}' but obviously that matches everything, i need to tell it to compare the NEXT line not the current one
<1> strerror_work: Use a buffer.
<0> pr3d4t0r: back
<0> pr3d4t0r: give me an example to allow me to continue being lazy and not have to look it up ? :)
<1> 3 minutes - phone. Please stand by.
<1> Two minutes.
<0> pr3d4t0r: np, thanks
<1> strerror: G/f is attending a business conference and I'm giving her advise, etc.
<1> strerror_work: Still here - wrapping up.



<1> strerror_work: OKi, I'm here 100%.
<1> strerror: Let me describe the solution first, then show you an implementation. Maybe the description alone will help you get to where you want.
<1> strerror: You need to have a sentinel, or variable that tells you what the $0 in the previous record was.
<1> strerror: And you need to store $0 (whole line) as well, in case that you have a match.
<1> strerror: You initialize these two to some value that doesn't exist in your input file.
<1> strerror: As your script takes one line at a time, you then compare the current $0 with the sentinel. If they match, you print the one that was stored (or the current one).
<1> strerror: Either way, you always set the sentinel to $0 by the end of the processing block, so that the current $0 becomes the sentinel for the next iteration.
<1> strerror_work: That's it.
<0> pr3d4t0r: back
<1> strerror_work: Nice :)
<1> strerror_work: Check out what I wrote. If that doesn't work, then we can do some code together.
<0> pr3d4t0r: yeah that makes sense, except that i need to print out both and i just want to match the first field of the line, but thats trivial to change, thanks
<1> strerror_work: Yeah. Then you just printf("Previous: %s\nCurrent: %s\n", previousLine, $0);
<1> strerror_work: I'm going to start getting ready for going out tonight. I'll be in-and-out for the next 10 minutes, then I'll drop off.
<0> pr3d4t0r: i'm about to head to bed myself, i'll write up something tmrw, thanks for the direction
<0> pr3d4t0r: or more accurately i got caught out fixing other people's problems, i'll sort my own tmrw ;)
<0> pr3d4t0r: feel free to show me an implementation if you have time, off to bed
<1> strerror_work: OKi - I'll just talk to you tomorrow then :)
<2> mooh
<3> hi
<3> small question: i have a file in which there are blocks of the type BEGIN:VCARD..END:VCARD. in those blocks, there can be the string BDAY:... if so i want to extract the line which starts with BDAY and the line which starts with FN: (in that specific block).. is that possible?
<4> xmb: you awake m8?
<1> Hello.
<1> _ke: Ping...
<1> _ke: Yeah, it's possible. I do that all the time to format the data from vCard (Palm) to put in my phone (Sagem).
<3> pr3d4t0r, thats cool
<3> pr3d4t0r, do you have some scripts?
<1> _ke: Did you figure it out?
<1> _ke: None that will do what you want.
<3> pr3d4t0r, the birthday yes ;)
<3> its working now
<3> do you have some other tips?
<1> _ke: Paste two or three sample records in the pastebin (http://eugeneciurana.com/pastebin) and I can give it a shot at writing something that'll do what you need.
<1> _ke: Not really. If you got it to work, then that's what counts :)
<3> what scripts are you using for your palm?
<3> pr3d4t0r, ? :)
<1> _ke: Oh, some scripts I made.
<1> _ke: Hold on.
<1> _ke: http://eugeneciurana.com/pastebin/pastebin.php?show=1518
<3> ive done that more simply: csplit /tmp/Contacts.vcf "/^BEGIN:VCARD/" "{*}"
<1> _ke: I had to make individual files of each record to put in my phone.
<1> _ke: That's what the extra code is for.
<1> _ke: The other thing is that I only cared about name and phone numbers out of the whole record. I don't care about having address, email, etc. information in the phone since I have all that in the Palm, and I use the Palm for email, etc., not the phone.



<3> ;)
<3> ok
<3> is that your only script?
<1> _ke: For this purpose, yeah.
<1> _ke: If you want scripts that do real work, google for LogCop IDS
<2> pasta-bin
<1> xmb: Pasta ****s when compared to the delicious Vietnamese sandwich I'm having for breakfast.
<2> mmm
<2> gimme money gimme jouwels - everything
<2> including sandwidthes
<1> xmb: http://www.yelp.com/biz/hqQoVK0vadOX7_4gN1sh3g - I'm having some of these for breakfast.
<1> xmb: Notice how most reviews are 5-star.
<1> xmb: The most expensive sandwich there is $2.75, and I bet you can't finish it even if you are a big eater.
<1> xmb: If you make the mistake of trying to stop by close to lunchtime, you won't be able to get your sandwich without waiting at least 30 minutes.
<2> saigon sounds technical
<2> looks good
<1> xmb: Best sandwiches in the city.
<1> xmb: I dropped my girl at work and I was driving by Saigon Banh Mi and thought, "Hrm... breakfast..."
<2> dropped like left?
<5> What variable determines the number of fields in a line?
<1> TSCDan: The separators in between them.
<5> I mean the actual number of fields though
<5> THink I just found it in the FAQ... NF?
<1> NF
<2> number of fields =)
<5> Thanks :)
<4> pr3d4t0r: that place looks good!
<1> igli: Are you a local?
<5> How can I tell awk to treat anything inbetween quotes as one field, even if it contains spaces? Ex: "Test, test2", test3, test4 should only show 3 fields, but it currently shows 4
<4> pr3d4t0r: no, been to SanFran tho
<1> Ah.
<1> TSCDan: Can you please show a full line of sample input?
<1> TSCDan: Is it something like a b "c d" e f ?
<5> "Last, First" 1234 4321 Dept
<5> That would be an example
<1> TSCDan: OKi.
<5> So similar concept to your example
<1> igli++
<1> TSCDan: Hrm... interesting.
<5> Yeah...
<1> TSCDan: One of the regex weenies can probably help.
<1> Hrm... wait.
<1> Commas only *inside* quotes?
<4> pr3d4t0r: :)
<5> Yes
<1> Hrm....
<1> TSCDan: Since I don't l;ike regular expressions I'd just make it algorithmic somehow.
<1> TSCDan: Mostly because I could hack something up faster than the time I'd spend ****ing with regex to get the right answer.
<5> Ok... say if the only space was next to the comma... how can I change the field separator to a tab?
<5> FS="\t" ?
<1> TSCDan: Yeah.
<5> Got it, Thanks :)


Name:

Comments:

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






Return to #awk
or
Go to some related logs:

fc5 raid5 grow
ubuntu multihoming
#osdev
#perl
failed to determine the netmask of !
#perl
#ati
phpmyadmin cnahge charset
perl string to hex unpack
#ldap



Home  |  disclaimer  |  contact  |  submit quotes