Solved

Find in unix for jar files

Posted on 2006-07-04
6
2,405 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
Comment Utility
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
Comment Utility
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
Comment Utility
this command results in response, can not create
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
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
Comment Utility
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
Comment Utility

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now