Solved

Find in unix for jar files

Posted on 2006-07-04
6
2,415 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

773 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