Thu 28 June 2012
Unfortunately this only works in BASH 4.x, which is a damn shame. Older
RHEL installations don't have the latest, greatest version of BASH
installed. If you're an admin of RHEL4/5 machines, this might be worth
trying to update, otherwise just write your automation in Python. :)
[sourcecode language="bash …
Continue reading »
Thu 17 May 2012
I recently needed to trim the last N characters from a string in shell.
I wrote this little function to handle the task.
This requires a newer distro that has updated coreutils that includes
the 'fold' command (Feb 2010).
#!/bin/bash
function trimChars() {
if [ $2 ]; then
TRIM_LAST=$2
elif …
Continue reading »
Thu 19 May 2011
Tags:
I always seem to forget these and are oh so useful.
Expressions used with
if
Continue reading »
Fri 12 February 2010
I do and do not recommend learning this.
Advanced BASH Programming - String
Operations
They certainly can come in handy though if you don't want to do some
basic grep/awk work.
little example:
$ foo="my words" $ echo ${foo#my} words $ echo ${foo:1} y words $ echo ${foo:2} words $ echo …
Continue reading »
Wed 22 July 2009
Tags:
I was about to upload some documents to my company's wiki that someone
else wrote. Upload failed! For some odd reason they chose to use a '+'
instead of a space or under bar in the filename. Here is how I fixed it.
for i in `ls -1`; do
old=${i …
Continue reading »