The UNIX and Linux Forums  
Hello and Welcome from to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
result of ftp MeeraNair UNIX for Dummies Questions & Answers 6 05-29-2008 10:27 AM
display the result of wc -l with words before and after the result melanie_pfefer UNIX for Dummies Questions & Answers 3 04-30-2008 08:33 AM
awk to output cmd result IMTheNachoMan HP-UX 4 04-27-2008 10:41 AM
Outputting formatted Result log file from old 30000 lines result log<help required> vikas.iet Shell Programming and Scripting 5 12-02-2007 10:43 PM
diff 2 files; output diff's to 3rd file blt123 Shell Programming and Scripting 2 05-28-2002 12:29 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-22-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
ls -R and then diff on those result

Hi,

I have two similar directory structures. One is the latest dev environment and the other is a previous version of the same dev environment.

I need to do a diff on the .cpp .c .java and .h files.

Hence I need a list of all the files of the above pattern so that I can diff then accordingly.



I thought on the following lines:

for i in `ls -R`
do
if {file ends in .cpp || .c || .h || .java}
put $i in fille.txt
done.

I need a script version of
if {file ends in .cpp || .c || .h || .java}


The reason for ls -R is different level of directories.

Vino
  #2 (permalink)  
Old 02-22-2005
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
one way....
Code:
#!/bin/ksh
......
for file in $(ls -R)
do
   if [[ "${file}" == *.@(cpp|c|h|java) ]]; then
      echo "file->[${file}]"
   fi;
done
  #3 (permalink)  
Old 02-22-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
one more way using find ...

Code:
find . \( -name "*.cpp" -o -name "*.java"  -o -name "*.h" -o -name "*.c" \) > x
  #4 (permalink)  
Old 02-23-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Thanks VG and Bhargav,

Not what I was looking for. Thanks anyway.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0