directory

Where is Perl looking for modules to include?

I started working on a new Unix system yesterday -- an HP-UX system I've never worked on before -- and I quickly realized that I needed some Perl modules installed. While working with another person the question quickly came up, "How do you know where Perl is looking for currently installed modules?"

A shell script to search multiple jar files for a Java class or pattern

I've found that there are several times when I need to be able to find a Java class inside of a jar file. Usually this happens when something isn't working, and I get something like a Java ClassNotFoundException. In the process of debugging this problem -- especially if I'm using a jar library that I haven't used before -- I list the contents of one or more jar files to debug the problem.

Linux find command recipes

Thinking about my own work when using Linux and Unix systems, a lot of the work is based around files, and when you're working with files, tools like the Linux find command are very helpful. So, I've decided to put together this list of find command examples/recipes that I'll update from time to time when I use the find command in different ways.

How to find all files beneath the current directory that end with the .jsp extension:

A Bourne shell script that loops through all files

Linux shell script for loop FAQ: Can you share an example of a Linux shell script for loop, for instance, to do something for every file in the current directory?

Here's a shell script that you'll find on all the Unix, Linux, and Mac OS X computers I've worked on. The general process of this script is "for every file in the current directory do XYZ".

How to use the Commons IO project to create, delete, and move files and directories

I wrote the following Java class today that is a "helper" class for a project I'm working on to create a web interface for Nagios. The Nagios part isn't too relevant, because mostly what I'm trying to show here is how to use the Apache Commons IO project to make it easier to interact with files and directories from Java code.

In short, the following Java class shows how to use the Commons IO project to accomplish the following tasks. Without any further delay, here is the complete source code for my class:

Java - How to delete a directory tree

Java directory FAQ: "How do I delete a directory tree in Java?"

Java delete directory - discussion

The delete method of the File class won't delete a directory tree, meaning that in the old days you had to write your own recursive method to do this.

Java Directory FAQ: How do I walk a directory tree?

Java directory FAQ: How do I walk a directory tree and do something with the files and directories I find?

I've done this recently by extending the DirectoryWalker class of the Jakarta Commons IO project.

Shell script error - bad interpreter - No such file or directory

Some times when you take a file from a DOS/Windows system and move it to a Linux or Unix system you'll have problems with the dreaded ^M character. This happened recently when I moved an Ant script from a Windows system to my Mac OS X system. When I tried to run the shell script under the Mac Terminal I got this error message:

: bad interpreter: No such file or directory

I couldn't figure out what the message meant at first, but finally it hit me: the dreaded ^M problem. Sure enough, I opened the file in the vim editor, like this:

Java File IO - How to test whether a file or directory exists

Java File I/O FAQ: Using Java, how can you test to see if a file or directory exists?

Java test to see if a file or directory exists

Answer: Here's a sample Java method that shows this test. All you have to do is use the exists() method of the File class (java.io.File) to perform this test.

AppleScript Finder tip - Get the full path of the Finder

AppleScript Finder FAQ: How do I get the full Finder path in an AppleScript script?

Syndicate content