• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Help with Unix commands

mAdMaLuDaWg

Platinum Member
So I have a lot of Java applications on my servers all having their own folder from the applications subdirectory. Now, I need to do the following.

Search all the applications subdirectories for message.jar.

If the message.jar file exists, I need to search the application directory for license text.

For example, my application subdirectory consists of the following application folders.

application/messagingApp/
application/databaseApp/
application/toolsApp/

Now when I run the following command from :/application:

:/application % find . message.jar -print

I get the following:
application/messagingApp/common/jars/message.jar
application/toolsApp/jars/message.jar


Now, since I know that the messagingApp and toolsApp contains message.jar, I now need to search all files in the directory (subdirectories don't have to be searched) application/messagingApp and application/toolsApp for the
following text: licenseKey=, and if it doesn't exist, I need to know what the application folder is.

For example, application/messagingApp/licensing.prop contains licenseKey= but there is no file in application/toolsApp that contains licenseKey= and toolsApp should be the output of the program.

I really have little experience with shell scripting so if someone can give me a few pointers, it would be much appreciated.

So I have the following command, to get the applications to gets each application directory that contains the message.jar file.

find . -name "message.jar" 2> /dev/null | cut -d "/" -f 2

Now, I just need to figure out how to write a command/script that uses that output to search for a licenseKey= in each application subdirectory and if it is not present, spit the application name out...
 
This is in tcsh lingo:

#!/usr/bin/tcsh
set dirs = ` find . -name "message.jar" 2> /dev/null | cut -d "/" -f 2 `
foreach dir ( $dirs )
find $dir -type f -exec grep -l "licenseKey=" {} \;
end
 
Originally posted by: degibson
This is in tcsh lingo:

#!/usr/bin/tcsh
set dirs = ` find . -name "message.jar" 2> /dev/null | cut -d "/" -f 2 `
foreach dir ( $dirs )
find $dir -type f -exec grep -l "licenseKey=" {} \;
end

Hey thanks for the help.

That sort of worked.. it also listed all subdirectories in the application directory that didn't contain the text licenseKey.

I have written another script that basically greps through appropriate files for the text "licenseKey=". The reason I did this was because certain application directories may need to have the text in a certain file. The script is called grepLicenseKey and it just a bunch of grep commands. I would like to call this script to report on an occurence of licenseKey instead of just a plain old grep.

So basically I need to do something like this:

#!/usr/bin/tcsh
set dirs = ` find . -name "message.jar" 2> /dev/null | cut -d "/" -f 2 ` | uniq
foreach dir ( $dirs )
if(exec grepLicenseKey $dir==null)
print "$dir";

end

What would be the shell script equivalent of the above?

Thanks again for the help. Its much appreciated!
 
Back
Top