![]() |
awk, cut, and sed
I just can't seem to totally wrap my head around pulling out strings of data from commands with awk, cut, and sed.
I can get grep, but grep isn't always the best answer. Anyone got any good resources explaining these binaries? |
I think cut is a fairly limited tool (no regex support or even wildcarding that i know of). I would say a google on these...
'sed tutorial' 'awk tutorial' ...would probably yield mass quantities. It did for me in the past. Naturally, hunting around oreilly.com will produce both online articles and books on the subject. I "cut" my teeth on 'Classic Shell Scripting' where chapter 3 provided most of what i use now (other than man awk and man sed and man regex, etc). But it's certainly possible to find an entire book about them. The 'The GNU Awk User's Guide' over at gnu.org is fairly definitive... as is the 'Advanced Bash-Scripting Guide' over at tldp.org |
GNU sed documentation:
http://www.gnu.org/software/sed/manual/ GNU awk documentation: http://www.gnu.org/software/gawk/manual/ nice article on awk: http://www.ibm.com/developerworks/li...ry/l-awk1.html http://www.ibm.com/developerworks/li...ry/l-awk2.html http://www.ibm.com/developerworks/li...ry/l-awk3.html |
Thank you book marked those for when I got more time to get down to it. However, I have a project on the back burner that I want to develop an open source package for OS X and release it for free, which will use a lot of under the hood scripts to accomplish what I want it to do.
Thanks Tom |
Awk is good for 1 liners. Much more than that and perl is probably better. Awk works oddly on Macs - it is pretty slow. I've never tried compiling it. I seem to recall that there is a post here somewhere that explains why it is slow.
Sed, well, I've never managed to do anything in sed other than substitutions. The o'reilley book sed and awk is a good one. Just buy an old edition off of ebay for a couple of bucks. Is this the hardware inventory project? Good Luck, Brett |
Quote:
So, I wrote a script that takes screen shots every 5 minutes, puts a stamp of the current user name with the time and date, and then saves them in a private folder hidden in the under the hood Unix. I just haven't had time to get back to it yet to wrap it up in a PKG and be able to give it to "the Internet Police" here at work. There are apps out there that do this, but they are $30 to $40 per a license and well, we have over 6,000 macbooks and probably another 3,000 Mac desktops. I was also just told we are finally scrapping all of our eMacs and replacing them with new iMacs in the middle schools, so I will be imaging and rolling those out as well soon. |
Just out of curiosity, is just for school provided internet, or at all times?
If just at school, it seems like you could send all the info to a database and be able to do some mining. But then you are back to perl :) Brett |
Since they take the laptops off campus, they need to be filtered at all times. If you want to read the nitty gritty of it you can look up CIPA (child internet protection act) which outlines all the federal stuff we are forced to do with children and the internet.
We actually got audited by the feds last year, and they came out and audited our filtering systems. I guess if you don't comply you can lose erated funding? I am not sure the exact penalties of not being in compliance but they are something we don't want. Every time a student complains to me about Internet filtering I tell them it is a federal mandate and for them to write their representatives in government if they want it changed.:) |
Quote:
Well I called my congressman and he said Quote: "I'd like to help you son but you're too young to vote" Trevor |
Quote:
|
Quote:
How do you make sure that they aren't hacking? Do you have the authority to disable the computer if the student doesn't comply with the policy? Just curious, Brett |
Quote:
It is just like working at a company, except in the school system you get in trouble and maybe at worst get suspended where as in the real world you lose your job. I have extensive reporting policies in Casper with email notifications and of course ARD admin. To be honest most of the time I am way too busy to spy, but if some school administrator or director asks me to pull info on a certain laptop I do it. Plus the reports and usage logs are there as a paper trail. |
Quote:
|
Well I am using it more and I think I got the hang of it for plucking out info that I need.
|
Quote:
CIPA does not require the tracking of Internet use by minors or adults. from here: http://www.fcc.gov/cgb/consumerfacts/cipa.html Does that make your job easier? |
Quote:
|
Quote:
Too bad I'm not a lawyer; I smell money here... :) |
What info are you after? If this is being done on a local machine then `screencapture` with date for the filename should be all you need.
Do you want to grab the iSight image as well? Surprised some libertarian parent hasn't sued someone over the monitoring. |
Quote:
I have a launchd item written and a shell script that uses the screen capture command, it then outputs a file to a hard coded destination. It names the file the current logged in user and adds a date stamp to the file name. I used awk to get the current logged in user since launchd scripts run as root. My problem is, I want a GUI that will control and unload and load the launchd item, will set the directory to save the file in, and will set the interval of how often the script runs, eg every 5 minutes, every 2 minutes and so forth. Then I want an option in the GUI front end that will unload the launchd item and will stop it from running. I know how to do all of this from the command line, I have no clue how to tie it to buttons on a little interface and have it write to the files it installs to configure the launchd and script settings. I think I may pick up a book or two on xcode and objective c. |
Seems like a perfect job for Applescript and / or Interface Builder.
There's a slightly dated thread specifically about building a GUI for a shell script around someplace. |
Quote:
|
Quote:
|
| All times are GMT -5. The time now is 10:17 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.