45 lines
6.9 KiB
Plaintext
45 lines
6.9 KiB
Plaintext
|
|
Episode: 2613
|
||
|
|
Title: HPR2613: Quick Awk Tip
|
||
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr2613/hpr2613.mp3
|
||
|
|
Transcribed: 2025-10-19 06:33:51
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
This is an HPR episode 2613 entitled Quick Locked Tip and in part of the series Learning Org.
|
||
|
|
It is hosted by Klaatu and in about 8 minutes long and carrying a clean flag.
|
||
|
|
The summary is this is a tip about Org crypt.
|
||
|
|
This episode of HPR is brought to you by archive.org.
|
||
|
|
Support universal access to all knowledge by heading over to archive.org forward slash donate.
|
||
|
|
Hey everybody this is Klaatu thanks for listening to Hacker Public Radio.
|
||
|
|
This is just a quick little tip I have because it's something that tripped me up and I figured maybe it would hinder someone else.
|
||
|
|
And anything standing in the way between you and Org needs to be eliminated.
|
||
|
|
So I've been listening to the really really fantastic series on Org by Dave Morris and Be Easy and I mean it's great.
|
||
|
|
I sat down with a computer and a notepad and I just listened to all of the episodes back to back and I use Org now.
|
||
|
|
I just use it when I want to do something I use Org. It's easy. I mean not everything but some things.
|
||
|
|
So it's been a great series and I've learned a lot but there was one little weird trick that if you try it you won't believe what happens next.
|
||
|
|
So this is probably really obvious to most people but it's just one of those things that it escaped me until until I realized what I'd done so quick tip.
|
||
|
|
Now here's a quick we just need something that works so really quickly we'll just do a get blame on food.txt and we'll assume that we get lines and lines and lines of commits by Klaatu.
|
||
|
|
So we're just going to do a quick find and replace. So we'll pipe the output of get blame to Org and then we'll do a parenthesis or a single quote begin.
|
||
|
|
All in capitals brace fs for the field separator equals quotation mark left parenthesis close quotation close brace and then we'll search for Klaatu.
|
||
|
|
So forward slash Klaatu forward slash that's the search and then a brace and we'll do a g sub parenthesis quote Klaatu quote comma quote gort quote close parenthesis semicolon print dollar sign to close brace close single quote.
|
||
|
|
So all we're doing is we're saying whatever we get out of get blame if you see the string Klaatu swap it out with gort and sure enough that that works okay.
|
||
|
|
So now I'm going to take all of that ock stuff and we're going to put it into a script called I don't know hpr dot ock so I'll open that up I'll paste it in and of course you probably know first of all that we don't need the single quotes.
|
||
|
|
So I got rid of those and then I'm doing the begin block as a nice little nice little.
|
||
|
|
Like a normal looking function block this isn't part of the tip this is just me formatting a script and then at the top of the file this is the tip of course you have to do your little.
|
||
|
|
Shabang thing right so you you need to know first of all where ock is on your system so I'll go to a terminal and I'll do which ock so it's user bin ock which I'm assuming is probably actually we do a like a read link.
|
||
|
|
dash f on user bin ock yeah it's actually slash bin gock dash 413 or 4.1 dot 3 but that's fine so I'm just going to use the little the alias so user bin ock and I'll save it so this is the tip because that's what I did the first time I thought okay well I'm finished doing all this stuff on the.
|
||
|
|
You know as as as on demand commands I want to make scripts that I can run repeatedly so I'll do the same thing as I did before the same kind of.
|
||
|
|
Instigation command get blame food on txt and I'm going to pipe it to something right so I'm going to pipe it to dot slash what I call hpr dot ock well first of all as I'm attempting to tab.
|
||
|
|
It's it's not working so that's something right there there's some things up with with this script already well of course the thing that I didn't do is to mod it plus X that's still not the tip.
|
||
|
|
So I did that so now I'm going to do get blame on food at txt I'm going to pipe it to dot slash hpr dot ock this time it sort of works at least tab completes and I hit return and I get a bunch of errors and this is what happened to me the first well it happens to me at the first couple of times because I.
|
||
|
|
I kept forgetting to do it so ock command line one syntax error command line ones terminated redgex so in other words it appears to be interpreting dot slash hpr dot ock as the ock command well why is it doing that I couldn't figure it out for the longest time and a lot of you are already telling me what I did wrong but some of you don't know and if you don't know this episode is for you.
|
||
|
|
Open up your script again and on your shabang line you have to do hash exclamation slash user slash bin slash ock space dash f that was what I didn't do so now if I do get blame food at txt pipe it to dot slash hpr ock I get a bunch of commits by clat to by gourd huh see what I did there so yeah that's that's what you have to do it's it's if you're if you're doing the ock script in a in a file.
|
||
|
|
You can't just say it's user been ock you have to say user been ock dash f if you do not do the dash f on your shabang line it basically won't work although there is a work around you can just pipe you could do a get blame food at txt pipe ock dash f dot slash hpr dot ock then then you're you're doing the same thing right you're you're invoking ock with the dash f to say hey this is the file.
|
||
|
|
I want you to run the contents of but if you don't want to do all that and I think with scripts you normally don't you want to just kind of act as a self as an apparently self sufficient executable is what you want it to appear as so you do a dot slash food at ock and it just runs as a program and that's that's what it'll do here it runs as a program because it's shabang line tells it that it's initial command is ock dash f that's my tip hopefully it helps some people who might run into problems as they do.
|
||
|
|
They're ock homework to be fair Dave and Yeezy might have covered this in one of their episodes but I felt like if not I mean I don't remember it ever being said explicitly it probably was but either way I just felt if it screwed me up then probably it would be helpful to do a tip episode about it on
|
||
|
|
hacker public radio hence this episode. Thanks for listening. Talk to you next time.
|
||
|
|
You've been listening to Hacker Public Radio at Hacker Public Radio dot org. We are a community podcast network that releases shows every weekday Monday through Friday.
|
||
|
|
Today's show like all our shows was contributed by an HBR listener like yourself. If you ever thought of recording a podcast then click on our contribute link to find out how easy it really is.
|
||
|
|
Hacker Public Radio was founded by the digital dot pound and the infonomican computer club and it's part of the binary revolution at binrev.com. If you have comments on today's show please email the host directly leave a comment on the website or record a follow up episode yourself.
|
||
|
|
Unless otherwise stated today's show is released on the creative comments, attribution, share a live 3.0 license.
|