I have a symbolic name java or jre or jre1.5 or jre1.6 or java1.5 or java1.6 that will point to the respective directory. Taking into account the first instance, it will look like:
java -> /usr/java/jdk1.5.x.x
My aim is as follows:
- To check whether the symbolic exists or not
- To get the value of the directory it is pointing
- To use regular expression instead of using if-else statement in the code.
The link will be in /usr/tmp.
I wrote some code in Perl which is as follows:
$filename = "/usr/local/java";
if (-l $filename) {
print "File exists \n";
} else {
print "Not \n";
}
But in case java is not present and instead java1.4 or java1.5 is present I want to search which should start with java and is a symbolic link.
Also I need to get the directory that it is pointing. Please advice how to proceed.