Execution problems with the jar -tvf command and "if" logic


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execution problems with the jar -tvf command and "if" logic
# 1  
Old 01-04-2011
Execution problems with the jar -tvf command and "if" logic

Hi,

I am reading a directory that has a list of jar files. I am searching these files for specific keywords. What i would like to do is write the address of the jar file to a new file if the search result is returned as false. For example;

Code:
 
/home/user/JarDirectory/Examplefile.jar

is the file i am searching.


Code:
 
 
cat $JarDirectory | jar -tvf $i | grep -v car

where $i is the current jar file being read.

If the grep -v command returns false i.e. the word "car" was not present in the file, then the address

Code:
 
/home/user/JarDirectory/Examplefile.jar

is written to a new file instead of the actual content of the file itself.

i am currently using an if statement with a test case e.g.

Code:
 
if [ $? -ne 0]
then
"write address of current jar file to Newfile"
fi

However i cannot get the logic right and i keep writing the content of the jar file to a newfile instead of the address of the jar file itself.

Any help would be greatly appreciated.

Apologies in advance if code was not bracketed properly.
# 2  
Old 01-04-2011
Imho this line does not make sense.
Quote:
cat $JarDirectory | jar -tvf $i | grep -v car
What is the value of $JarDirectory ?
Does it point to a file or a directory?
If it is a file, what is in the file?

Are you looking for the string "car" in the name of a file in each archive or are you looking for the string "car" in the contents of each file in each archive.
# 3  
Old 01-04-2011
Hi Methly,

Quote:
$JarDirectory
is a path leading to a directory that contains the jar files.

I am looking for the string "car" in the contents of each file in the directory.

I have it solved now though.

Thanks for looking at my thread anyway.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

2. Shell Programming and Scripting

Want to write all the jar name in single with delimiter ":" in beween the jar name

Hi All, I am having 7 jar files in a dir. abc like listed below bash-3.00$ cd abc bash-3.00$ ls 123.jar 23wdawd.jar dfsa23.jar dsa.jar wew234.jar adsd234234.jar dfsda423.jarNow i want to assign all this jar files to a variable in the below format ... (6 Replies)
Discussion started by: natraj005
6 Replies

3. Solaris

How to avoid "cannot execute" issue with a runnable jar file?

I am trying to understand why the runnable jar file runs on one Unix server, but not the other with same environment settings. I copied exact same test jar from here --> http://www.javaworld.com/javaworld/javatips/javatip127/MakeJarRunnable.zip on to both Unix servers. Then changed... (5 Replies)
Discussion started by: kchinnam
5 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. UNIX for Dummies Questions & Answers

Problems with "sort" command

It seems our administrators had installed the version of the "sort" command not having the -M option. Does anyone have the source code for this routine? I need to be able to sort on month comparison: e.g. "sudo at -l | sort -k3M,5" (1 Reply)
Discussion started by: superdelic
1 Replies

6. UNIX for Advanced & Expert Users

Problems with "set pka0_host_id 6" command

I need to change the pka0_host_id 7 to 6 but the command "set pka0_host_id 6" returns "pka0_host_id protected from attempted operation". How can i do that? please i need some answers soon!!!!! thanx (1 Reply)
Discussion started by: Lestat
1 Replies

7. HP-UX

Problems with "show device" command

I have a DS25 and when i run "show device" don't appear my 'dka.....' and 'dkb....' devices, but i know they must be there, where could be the error? what can i do to see them? (3 Replies)
Discussion started by: Lestat
3 Replies

8. UNIX for Advanced & Expert Users

Problems with "show device" command

I have a DS25 and when i run "show device" don't appear my 'dka.....' and 'dkb....' devices, but i know they must be there, where could be the error? what can i do to see them? I'm using Tru64 PD: Im so sorry if i repeat this Q but i really need an answer and i dunno where to ask... (6 Replies)
Discussion started by: Lestat
6 Replies

9. UNIX for Dummies Questions & Answers

Problems with "set pka0_host_id 6" command

I need to change the pka0_host_id 7 to 6 but the command "set pka0_host_id 6" returns "pka0_host_id protected from attempted operation". How can i do that? please i need some answers soon!!!!! thanx (1 Reply)
Discussion started by: Lestat
1 Replies

10. UNIX for Dummies Questions & Answers

Problems running "at" command

I used to be able to run "at". Then I started getting "can't open job file in the /var/spool/cron/atjobs directory". Based on a newsgroup thread's advice, I logged in as root and entered "chmod 4755 /usr/bin/at" and then got "at: you are not authorized to use at. Sorry.". In trying to put... (4 Replies)
Discussion started by: cjhancock
4 Replies
Login or Register to Ask a Question