Absolute, Relative, and Splitting Paths in Bash

Tuesday, 1 December 2009 by Rob

The main stumbling block with splitting paths in Bash is converting a relative path into an absolute one.

Searching the Internet I found many partial solutions, but none was entirely satisfactory. There may be a better solution out there, but I didn’t find it.

Read the rest of this entry »

‘Upwords’ and ‘Downwords’

Saturday, 21 November 2009 by Rob

Running a simple script over a file containing a list of basic English words revealed the following (strict) ‘upwords’ and ‘downwords’, i.e. words with alphabetically or reverse-alphabetically ordered letters.

Read the rest of this entry »

Multi-anagrams

Saturday, 21 November 2009 by Rob

Running a simple script over a file containing a list of basic English words revealed the following groups of anagrams with at least 3 elements.

Read the rest of this entry »

Reversible Words

Saturday, 21 November 2009 by Rob

Running a simple script over a file containing a list of basic English words revealed the following reversible pairs.

Read the rest of this entry »

Palindromes

Friday, 20 November 2009 by Rob

Running a simple script over a file containing a list of basic English words revealed the following palindromes.

Read the rest of this entry »

Sample Repository Layout

Friday, 20 November 2009 by Rob

Batch / Bash: Output to STDERR

Friday, 30 October 2009 by Rob

To output a message to the error stream in a batch file, simply do this:

echo your message text 1>&2

Similar syntax may be used in Bash shell scripts:

echo "your message text" 1>&2

Read the rest of this entry »

Batch: Comparing Files

Friday, 30 October 2009 by Rob
The trick to testing file contents is to do something like this:

( fc /B "%file1%" "%file2%" | find "FC: no differences encountered" ) > nul && (
  echo "%file1%" and "%file2%" are the same
) || (
  echo "%file1%" and "%file2%" are different
)

using conditional execution.

Read the rest of this entry »

Batch: Testing for Empty Directories

Thursday, 22 October 2009 by Rob

To test whether a directory (or “folder”) is empty, the code

if exist "%dir%\*.*" (
  echo %dir% is non-empty
) else (
  echo %dir% is empty
)

does not work; it always reports “non-empty”.

The trick

( dir /b /a "%dir%" | findstr . ) > nul && (
  echo %dir% non-empty
) || (
  echo %dir% empty
)

using conditional execution, however, does work.

Read the rest of this entry »

JSP & JSTL: Setting a Variable to the Content of an XPath

Wednesday, 21 October 2009 by Rob

I had a problem in JSP and JSTL where I could not get a core variable to contain the content of an XML XPath expression.

Following a combination of reading a book, searching the Internet and speaking to a colleague, I found two solutions to my problem, but unfortunately not an answer to the question of why my original code does not work.

Read the rest of this entry »