Reg : binary files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reg : binary files
# 1  
Old 11-15-2007
Reg : binary files

HI Friends,

My actual requirement is to find out the binary files except txt/gif from parent and subdirectories. so,i have to write unix shell script.

Any one please suggest me on this how to write script for this or any other alternate way is there to find out.

Thanks & Regards,
Srujana
# 2  
Old 11-15-2007
You can use "find" to recurse through the directories.

How are you going to tell the difference between binary files and text files?
# 3  
Old 11-15-2007
Quote:
Originally Posted by porter
You can use "find" to recurse through the directories.

How are you going to tell the difference between binary files and text files?

really i am new to unix...
i am not sure how to differentiate, if you know please suggest me.
# 4  
Old 11-15-2007
Quote:
Originally Posted by srujana
really i am new to unix...
i am not sure how to differentiate, if you know please suggest me.

What is your actual requirement? What makes binary files special? Do you mean programs, ELF files or anything that has bit 7 set in any character?
# 5  
Old 11-15-2007
my actual requirement is,

I want to find out the text files(ex:.html,.txt) and binary files(ex:.jpg) from each directory. From binary files at last i need only .gif files, reamining all i have to ignore.

after getting result, I have to archive those files and needs to checkin into CVS.

I hope my requirement is clear now.
# 6  
Old 11-15-2007
Code:
find dir -type f | while read N
do
      case "$N" in
      *.txt | *.html )
              do whatever with text file "$N"
              ;;
      *.gif | *.jpg | *.jpeg )
              do whatever with binary file "$N"
             ;;
      * )
             ;;
      esac 
done

# 7  
Old 11-15-2007
Quote:
Originally Posted by porter
Code:
find dir -type f | while read N
do
      case "$N" in
      *.txt | *.html )
              do whatever with text file "$N"
              ;;
      *.gif | *.jpg | *.jpeg )
              do whatever with binary file "$N"
             ;;
      * )
             ;;
      esac 
done


Hi,

I saved above script with .sh and ran after that getting error "scrip.sh: syntax error at line 5: `do' unexpected"
in above script "N" means what, i guess its referring to dir path right? if its referring to dir path then where to mention path.

suppose, now i am in /home/coreadmin, now i have to check files from here, then how to mentation path in above script.

Thanks for your patience and help!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Binary files diff

Hi I am very happy to joined this group!!! I need your suggestion for get it resolved my issue. I have two class files both class files are same, there is no diff in both two files. Both 2 files were compiled in Linux environment with different type of OS. When i am using diff command,... (13 Replies)
Discussion started by: suresh1256644
13 Replies

2. Shell Programming and Scripting

Binary files

Hi All,Is there anyway I can conver the binary file to ascii. I don't know the binary file format. file command just lists this as "data" file and when I view it has a lot of non-printable characters.Can I write any command equivalent to wc -l to find out the number of rows in the file?Can I use... (4 Replies)
Discussion started by: rahulkav
4 Replies

3. Programming

Editing binary files

I am working in C and need a solution for below problem: I have a binary file, which needs to be edited in such a way no data is loss. For example i have to insert 3 bytes of data at some position without changing the contents of the file. if file has data as:... (2 Replies)
Discussion started by: junaid.nehvi
2 Replies

4. Solaris

doubt reg time stamp in files.

I copied a file from one host to another using sftp. But after copying the time stamp is not updating . Even though I checked the permission, it looks good. I copied the same file to some temporary location, there it updating the time stamp. Anyone have any idea on this (6 Replies)
Discussion started by: rogerben
6 Replies

5. UNIX for Dummies Questions & Answers

Reg: delete older files from ftp

Hi, I want to delete older files from ftp server. (files which are more than 5 days old). Please advice Thanks , sam (3 Replies)
Discussion started by: sam99
3 Replies

6. Shell Programming and Scripting

search for files excluding binary files

Hi All, I need a solution on my following find command find ./.. -name '*.file' -print BTW This gives me the output as belows ./rtlsim/test/ADCONV0/infile/ad0_dagctst.file ./rtlsim/test/ADCONV0/user_command.file ./rtlsim/test/ADCONV0/simv.daidir/scsim.db.dir/scsim.db.file... (2 Replies)
Discussion started by: user_prady
2 Replies

7. Shell Programming and Scripting

reg files

Dear all, One of our jobs retrieves data from tables and writes it to files. This job was running for around 15 minutes for the past 8 months. Now, this job is runnig for 45-50 minutes. I checked with the DBA's and found no issues with database. The time taken by to job to write to the file is... (5 Replies)
Discussion started by: ranj@chn
5 Replies

8. UNIX for Advanced & Expert Users

Files Linked With A Binary

Hi, What is command in unix to find what are all the files linked with an executable binary. Thanks in advance. Rgds, Omkumar (2 Replies)
Discussion started by: tc.omkumar
2 Replies

9. UNIX for Dummies Questions & Answers

Binary Files

Here's the problem... I'm using a simulator on UNIX, and it requires a filename where bits are stored, it should read them out and do whatever with them at that point.. So what i'm trying to do is make a binary file on UNIX. On my PC i can use MSDEV, or any of my C++ compilers to generate a... (2 Replies)
Discussion started by: wcRandThor
2 Replies

10. UNIX for Dummies Questions & Answers

Binary Files

Does any one know how to view a binary file as it is (in 1s and 0s) on unix environment? (1 Reply)
Discussion started by: devildivine
1 Replies
Login or Register to Ask a Question