Steve's Shell Coding Tips
This is the place for small, cool, interesting or just noteworthy shell scripting tips.
They also tend to be shared with the Facebook page.
I do, less frequently, write longer articles, at http://steve-parker.org/articles.
I also have some Linux Tips, which you may find interesting.
- Editing a line in a text editor - Copy a command into a text editor for further editing
- The 'cp -t' command - A rant
- Efficiently Pinging a Subnet - Two methods to use the ping command to quickly scan a network
- The strstr() function in bash - Using Bash's pattern matchin to implement the well-known strstr() function.
- Giving Developers Root Access - What Could Possibly Go Wrong?!
- Search and Replace within a Variable - Editing Contents of Variables
- Calculating Hours, Minutes and Seconds - This function uses Bash's simple built-in integer mathematical capabilities to display a duration (in seconds) in a more human-readable form
- Software Development models - Explained with Cars
- The O'Reilly Animals - An Adult Coloring Book.
- rm -rf / - A Confession.
- Where There Is A Shell, There Is A Way - There Just Is.
- Christmas - Using GNU Date to work out how many days until a given event (such as Christmas, 25th December)
- Shift - A quirk of the "shift" command explained. You probably did not know this.
- The Story Of Mel - A Real Programmer.
- chmod 777 - Not needed.
- Linux Administrator - the old "What I Do / What I Think I Do" meme.
- Progress Bar - Creating a simple Progress Bar for a shell script.
- Fork Bomb! - Using shell builtin commands to deal with a fork-bombed machine.
- Sorting on Fields - Understanding the 'sort' utility.
- Simple Shell Functions - A vital step on the journey towards shell scripting proficiency.
- Expanding Lists - a useful way of expanding lists automatically. Useful for Bart Simpson, useful for you.
- Expanding Sequences - a useful way of automatically expanding lists of numbers and characters. With Bash, you don't need to type "for x in 1 2 3 4 5", or do lots of other laborious typing. It can expand all sorts of numbers, and letters, for you, in ways that you probably never knew.
- Checking the exit status of ANY command in a pipeline - normally you only get the exit status of the last command in a pipeline - this way, you can get the status of any command in a pipline of any length
- Nifty use of Grep in a Loop that you wouldn't ordinarily think of
- RPM Package Versions and how to deal with awkward version numbers
- Trap Die Tip - the smart way to deal with errors
These should accumulate over time, to become a library of the useful, the quirky and the just plain odd.
Check out the new Shell Scripting Tutorial at www.shellscript.sh
Invest in your career. Buy my Shell Scripting Tutorial today:
See my other publications here: http://steve-parker.org/publications/.