Java Reference
In-Depth Information
The file looks at the first several hundred bytes of the file and does a statis-
tical analysis of the types of characters that it finds there, along with other spe-
cial information it uses about the formats of certain files.
Three things to note with this output from file . First, notice that
dispColrs was (correctly) identified as a PNG file, even without the .png
suffix that it would normally have. That was done deliberately to show you that
the type of file is based not just on the name but on the actual contents of
the file.
Second, notice that the .jar file is identified as a ZIP archive. They really
do use a identical internal format.
Thirdly, file is not foolproof. It's possible to have perfectly valid, compil-
able Java files that file thinks are C++ source, or even just English text. Still,
it's a great first guess when you need to figure out what's in a directory.
Now let's look at a file. This simplest way to display its contents is to
use cat .
$ cat Shift.java
import java.io.*;
import java.net.*;
/**
* The Shift object
*/
public class
Shift
{
private int val;
public Shift() { }
// ... and so on
} // class Shift
When a file is longer than a few lines you may want to use more or less
to look at the file. 6 These programs provide a screen's worth of data, then pause
6. Like any open marketplace, the marketplace of ideas and open source software has its “me-
too” products. Someone thought they could do even better than more , so they wrote a new,
improved and largely upward compatible command. They named it less , on the minimalist
philosophy (with apologies to Dave Barry: “I am not making this up”) that “less is more.”
Nowadays, the more is rather passe. The less command has more features and has largely
replaced it. In fact, on many Linux distributions, more is a link to less . In the name of full
Search WWH ::




Custom Search