?
Solved

Find in unix for jar files

Posted on 2006-07-04
6
Medium Priority
?
2,426 Views
Last Modified: 2007-12-19
Hi
I have MANIFEST.MF files in unix which didnt get converted to unix format and thus have ( ^M) charater. Now finding all the files with this character is an issue.

1. Need script to find ^M character in all the files in the dir and sub dir (if possible)

2. MOST IMPORTANT: Is there any way to search the jar files without unjaring them to find the ^M in the files where the end of line is supposed to be.  Because I am right now unjarring and re-jaring files which you can agree, is very inconvenient:)

Please reply for both questions (pls refer to each question and 1 or 2) as soon as possible.
Thank you
0
Comment
Question by:atwork2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 17040042
you can do:
#under the current dir:
find . -type f  -exec grep -l "^M" {} \; > filelist

where: ^M you need to type in: Ctrl v Ctrl M in your keyboard.
           all the filename stored in filelist.

Or for the whole system:
find / -type f  -exec grep -l "^M" {} \; > filelist
0
 

Author Comment

by:atwork2003
ID: 17043230
Do I have to give the name of each file in the file list with the above command. Thank you
0
 

Author Comment

by:atwork2003
ID: 17043300
this command results in response, can not create
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Expert Comment

by:ahoffmann
ID: 17043602
find / -type f  -exec grep -l "^M" {} \; > /tmp/filelist

> Do I have to give the name of each file ..
no, after command finished, see
  cat /tmp/filelist
0
 
LVL 48

Accepted Solution

by:
Tintin earned 2000 total points
ID: 17046300
A blanket way of ensuring all your jarfiles have Unix end of line characters is to do

find / -name "*.jar" -exec dos2unix {} \;

0
 
LVL 6

Expert Comment

by:JJSmith
ID: 17047089

1. Need script to find ^M character in all the files in the dir and sub dir (if possible)

find . -type f  -exec grep -l "^M\$" {} \; > /tmp/flist

#Create the ^M as suggested by ahoffman above.
#The additional \$ it to instruct grep to only identify ^M at the end of a line.
#if there are none text files is your search path they may contain the character code for ^M but it is a genuine value not a DOS end-of-line.

2. MOST IMPORTANT: Is there any way to search the jar files without unjaring them to find the ^M in the files where the end of line is supposed to be.  Because I am right now unjarring and re-jaring files which you can agree, is very inconvenient:

The same possibily occurs here is you simply check a complete .jar file for any ^M - is it a real value in a non-text file or NOT?

I think you have to have 2 stages here.

A.  use the same command as above to identify all files including .jar's.

B.  for each .jar file identified then unjar into a temp dir and run the command against that temp dir.


Cheers
JJ
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month11 days, 21 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question