• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2430
  • Last Modified:

Find in unix for jar files

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
atwork2003
Asked:
atwork2003
1 Solution
 
yuzhCommented:
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
 
atwork2003Author Commented:
Do I have to give the name of each file in the file list with the above command. Thank you
0
 
atwork2003Author Commented:
this command results in response, can not create
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ahoffmannCommented:
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
 
TintinCommented:
A blanket way of ensuring all your jarfiles have Unix end of line characters is to do

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

0
 
JJSmithCommented:

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now