Archive for December, 2006

How To Work Around “Argument List Too Long” Error Deleting a Gazillion Files Under Linux

Thursday, December 28th, 2006

You can receive the error argument list too long trying to execute a rm -f * in a directory with a lot of files but there is a very simple workaround.  Simply execute this instead to delete the files…

find . -name "*" -type f -maxdepth 1 -exec rm {} \;

Important: Executing a find . -exec rm {} \; is equivalent to executing a rm -f * — be sure you know what you are doing and be sure you are in the right directory when you execute this.

Note that the -name "*" switch avoids deleting system files and the -maxdepth 1 switch avoids deleting files in subdirectories.

How To Identify the Files/Directories Chewing Up Disk Space Under Linux

Monday, December 4th, 2006

If you are running out of disk space under Linux, here are three useful commands to help identify which files and directories are chewing up the most disk space…

  1. Show the 50 largest files…find / -path '/proc' -prune -o -size +1000k -printf '%s %p\n' | sort -k1 -g -r | head -50
  2. Show the 50 largest directories (excluding files in subdirectories)…du -kS / | sort -k1 -g -r | fgrep -v '/proc' | head -50
  3. Show the 50 largest directories (including files in subdirectories)…du -k / | sort -k1 -g -r | fgrep -v '/proc' | head -50

Important: As these commands may take a little while to run, you should not run these commands on a production system where a significant increase in load would have an adverse impact.

The 16 String Functions Available in JSP EL

Friday, December 1st, 2006

Although I’ve used JSP extensively for quite sometime, I didn’t realize until recently that JSTL supports 16 string functions within the EL syntax.  Here is an example JSP page that exercises the 16 string functions…


<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<html><body>

contains() --> ${fn:contains('Hello', 'el')}<br>
containsIgnoreCase() --> ${fn:containsIgnoreCase('HELLO', 'el')}<br>
endsWith() --> ${fn:endsWith('Hello', 'llo')}<br>
escapeXml() --> ${fn:escapeXml('1<>3')}<br>
indexOf() --> ${fn:indexOf('Hello', 'el')}<br>
join()/split() --> ${fn:join(fn:split('/1/2/3/4/5', '/'), ':')}<br>
length() --> ${fn:length('Hello')}<br>
replace() --> ${fn:replace('Hello', 'H', 'J')}<br>
startsWith() --> ${fn:startsWith('Hello', 'He')}<br>
substring() --> ${fn:substring('Hello', 2, 4)}<br>
substringAfter() --> ${fn:substringAfter('Hello', 'el')}<br>
substringBefore() --> ${fn:substringBefore('Hello', 'el')}<br>
toLowerCase() --> ${fn:toLowerCase('HELLO')}<br>
toUpperCase() --> ${fn:toUpperCase('hello')}<br>
trim() --> ${fn:trim('  hello  ')}<br>

</body></html>

This outputs the following…


contains() --> true
containsIgnoreCase() --> true
endsWith() --> true
escapeXml() --> 1<>3
indexOf() --> 1
join()/split() --> 1:2:3:4:5
length() --> 5
replace() --> Jello
startsWith() --> true
substring() --> ll
substringAfter() --> lo
substringBefore() --> H
toLowerCase() --> hello
toUpperCase() --> HELLO
trim() --> hello

You can see the full reference for these string functions here.  This requires JSP 2.0.

You can also find an excellent article on creating a custom JSP function here:)