Advanced Search
Search Results
30 total results found
How do I extract certain columns from a text file in Unix?
Somehow I can never remember the cut command in Unix. But I occasionally want to remove certain columns from a text file of data. cut will do that.DelimitedHere is a simple tab-delimited example. (Use the -d option to set a different column delimiter.)Data Fil...
Awk Explained
Awk is a Unix tool that can be very useful for dealing with text but can be hard to understand. Here are some useful explanations. awk is a beautiful tool Famous Awk One-Liners Explained, Part I 8 Powerful Awk Built-in Variables – FS, OFS, RS, ORS, NR, NF, FIL...
combining unix stderr output with stdout
The problem is that when I run script x and redirect it to a file, all of the error messages come to the screen when I want them to also go to that file.With bash shell, use:program > outputfile 2>&1My colleague found this for me in the book Unix Pow...
diff and patch
The Ten Minute Guide to diff and patch Using diff and patch
avoiding increasing indents while pasting into vi
When pasting text into a vi editing screen, sometimes you’ll get each line increasingly indented like this.aaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbb ccccccccccccccccccUse this command to change the “paste” setting. Then change it back when you’re done.:set paste:...
Unix grep, find and maxdepth
I’m writing this so I can find it next time I want to do this, and so my student programmers can more easily compare config settings across test sites.Problem: Find a particular line quickly in a file in 7 different directories. In this case, it’s a Moodle co...
15 Basic ‘ls’ Command Examples in Linux
I learned at least three things from this list, and I’ve been using ls for years.15 Basic ‘ls’ Command Examples in LinuxThe new things for me were: ls -lh – human readable format on file sizes ls -ltr – reverse output order, which is particularly useful when s...
cron job examples
Here are some interesting examples of cron job use. http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/ – I didn’t know about @monthly, @yearly, and @reboot, or changing the MAIL destination setting. http://www.pantz.org/software/cron/croninfo.h...
Linux performance analysis in 60 seconds
Here’s an intro to understanding what’s going on with a Linux server, quickly.http://techblog.netflix.com/2015/11/linux-performance-analysis-in-60s.htmlIf anyone has others, please post them here.
Regular Expressions
Regular Expressions are how you match text and patterns of text in a programming language, and once you learn it, it’s useful in many languages. Regular Expression Cheat Sheet RegExr is an online tool to learn, build, & test Regular Expressions CROSSWORDS ...
grep tricks
I’ve been using grep (Global Regular Expression Print) to search files on Unix for years and never knew you could have it appear in color. And here are some other interesting articles about grep. http://unstableme.blogspot.com/2009/03/highlight-match-with-col...
Apache log shell scripts
Return count of timestamps with most error logs. A couple years ago an app error_log reported about 16000 errors within a few seconds. After fixing it, we wanted to sort by number of errors per second. This does that. The first column is the count. cat /logs...