| |
| |
| |
|
Page: 1 2 3
Comments:
<0> Hi. What is a good way of printing every field except the first one? <0> From the man page: "Decrementing NF causes the values of fields past the new value to be lost, and the value of $0 to be recomputed, with the fields being separated by the value of OFS." <0> But how can I decrement NF? I tried several things. <1> redondos: print line excluding first word: awk '{for (i=2; i<=NF; i++) printf("%s ",$i);printf ("\n")}' filename <1> print line excluding first word: awk '{ $1 = ""; print }' filename <0> Awesome, thanks. <0> gnubien: Can you think of a way of doing it with the second command you suggested but also removing the leading space? <1> maybe <1> # delete leading whitespace (spaces, tabs) from front of each line awk '{sub(/^[ \t]+/, ""); print}' <1> http://www.student.northpark.edu/pemente/awk/awk1line.txt <0> Nice. <0> Is that page yours? <1> lots of cool tips at that url <1> no, i b just a awk user too <0> k :) <1> only be learning awk for about 6 months, always a newbie tho
<0> How would you print just the last line here: awk '/asdasd/ {$1 = ""; sub(/^[ \t]+/, ""); print $0 | "sort" }' <0> I can't think of a good way where to use END. <1> # print the last line of a file (emulates "tail -1") awk 'END{print}' <0> I got that, but where should I fit it in my statement? <0> I'll just use tail for now. <0> That page is really useful, thanks for that. <1> awk 'END{print}' filename | awk '{ $1 = ""; print }' |awk '{sub(/^[ \t]+/, "");print}' <1> i havent figured out how to combine awk without pipes yet; maybe a function would do that <0> Ah, 'print' is the same as 'print $0'? <0> album_id=$(awk '/asdasd/ {$1 = ""; sub(/^[ \t]+/, ""); print $1 | "sort"} | tail -n 1') <0> That's what I'm currently doing. <0> Doing all in one awk script would be nice. <1> no sort with awk <2> Heh. <2> You guys are really geeking out tonight :) <2> Kudos. <1> pr3d4t0r: yea, we b havin fun now ;) <1> pr3d4t0r: know how to chain awk commands together without using pipes? <0> Yeah, I'm trying to write a script to resize and upload pictures to a remote gallery2 (gallery.mentalto.com). <0> And awk has helped me greatly. <1> cool, awk is really uber-powerful, great utility <1> redondos: google gawk manual for lots of info <2> Ah, argentino. <0> :) <0> Where are you from? <2> redondos: Mxico. <0> Nice. <0> Sorry for the World Cup elimination. <0> Not that a geek would care, anyway. :) <0> Hey, the script is finally working. Neat. <2> Indeed. <1> great <2> redondos: I'm not shocked. We have some of the best players in the world -- as long as you don't put them all to play in the same team. <0> pr3d4t0r: Heh, I didn't know that was the general feeling in mexico. <1> http://www.grymoire.com/Unix/Awk.html <2> redondos: I don't know what the feeling down there is like, but I bet it's similar ;) <2> redondos: I haven't lived there in a long time. <0> I see. <0> gnubien: Is that the recommended tutorial? <1> http://www.vectorsite.net/tsawk1.html not official but good <1> http://www.grymoire.com/Unix/Awk.html really good and easy read <1> http://www.faqs.org/faqs/computer-lang/awk/faq/ <0> Swell. <1> cool, awk is easy to learn so i bet you will learn it fast <2> redondos: If you promise to be a good boyscout, and not to publish this bookmark... <2> redondos: Check your private messages. <0> pr3d4t0r: I haven't gotten any. :/ <2> redondos: Check now. <0> Oh, there we go. <2> redondos: Just keep that one to yourself. Some of those e-books, uh, fell off the back of a truck. <0> :) <0> There's little about awk, though. <2> redondos: Only one awk reference, from O'Reilly. That's probably all you need anyway. <0> Yeah... <2> redondos: Also, if you get the urge to download that let me know and I'll give you the URL for a CD .iso image instead that you can fetch with wget and pace down the rate of download. <2> redondos: That server is my gateway and it's under somewhat heavy use. <0> pr3d4t0r: I'd be glad to have that CD image. <2> redondos: Do you know how to pace wget? <0> yeah <0> Just tell me what rate you want me to limit it with.
<2> --limit-rate, set it to around 20 KB/s and you'll be golden so that other people keep good service to the server. Check your private messages in a few moments. <2> Grrr... <2> redondos: Hold on; I think I clobbered it by mistake. <2> redondos: Let me check my backups. <0> OMG. <2> redondos: Well, here's the good and the bad news. <2> redondos: It's backed up -- that's not a problem. <2> redondos: That's the good news. <2> redondos: The bad news is that it's backed up in a remote server so I need to bring it across first, and that will take a while. <0> pr3d4t0r: No worries, just please ring me a bell whenever it's ready. :) <2> redondos: If you don't mind, check with me tomorrow. I'm more-or-less always around IRC :) <0> k <2> redondos: It looks like I found a DVD backup here. Stand by. <0> k <2> redondos: Checking... <2> rdir -s /home/ciurana <2> ... <2> Sorry. <2> Hah! <2> I just found my C++ code from 1990 - 1996. <0> Heh... <2> redondos: Ping me tomorrow - no luck right now. <0> k <3> hi! <3> i have a file with column separated by ':' 'FO:BA:qwer' how convert it to 'FO:FO-BA:qwer' so copy the first column at the beginning and change the second ':' by '-' <4> { print $1":"$1"-"$2":"$3 } may be <3> and instead of using '$3' could ise use something to indicating that add the rest <3> i say it because there are more fields <4> BleSS: am there at #bash also :) <3> m4n, sorry :) <5> i need to filter a file using awk contanis the following first line "AA","BB","CC",..... and second line "11","22","33",... i want to have the output in this way capture only the data that i want BB 22 FF 55 any help <2> karma pr3d4t0r <6> pr3d4t0r++ <2> genocide: He, he, he... thanks. I was in the wrong channel :) <2> genocide: How are you? <6> np <6> im good.. no more headaches.. had em for weeks now.. stopped smoking dope excessive.. and theyre gone like that.. <6> how are you ? <6> ;) <2> genocide: Just busy. <2> genocide: Nothing special. <6> okay <2> genocide: I have a book coming out on 10.October and we're doing the final editorial p***. That, combined with work == pr3d4t0r has no life :) <6> oh, word <6> whats the title ? <6> whats it about ? <2> genocide: It's a novel. <2> genocide: http://www.teslatestament.com <6> oh <6> looks interesting <6> remind me buying it :D <2> genocide: I will :) <2> genocide: I'll be pimping it all over Freenode when it's out ;) <2> genocide: Nothing too overt, of course, or tag_ will /ban me from here, but I'll let you guys know :) <6> cool, thanks :D <6> "Recovered by intelligence agent pr3d4t0r (JANAP/299: ZEPHYR) and recently decl***ified." <6> heh.. <2> Shush! <2> genocide: :) <6> :P <6> but is there any truth within that story? i dont know much about tesla's work <6> nor his history.. <6> i am not very well educated.. <2> genocide: All the Tesla-related stuff is based on facts known and documented about Tesla's life and work. <6> really ? <2> genocide: Really. <2> genocide: Fact-based fiction is where it's at, baby! <2> :) <6> did the us.gov burrie his work ? <2> genocide: Yup. <6> omg <2> genocide: Through the Office of Alien Property, though by then Tesla had been a US citizen for over 40 years. <2> genocide: That sheet that pr3d4t0r "recovered" is really a document obtained through FOIA. <2> genocide: It's a real document. I think I lifted that one from the PBS Tesla web site.
Return to
#awk or Go to some related
logs:
frostwire java ubuntu symlink #linux #suse #perl #perl coreymerlin /dev/snd missing udev gentoo structure of ibubrophen QMYSQL3+ubuntu rhapsody ubuntu chroot
|
|