Solved

Find in unix for jar files

Posted on 2006-07-04
6
2,417 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
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
remove a combination of patterns from a file 15 71
Sed question 2 102
Adding a continue option in a script 9 55
Retreiving column names in Windows but not in Unix 11 58
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

829 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