UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old November 8th, 2004, 02:12 PM
miry2j miry2j is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 37 miry2j User rank is Private First Class (20 - 50 Reputation Level)miry2j User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 h 35 m 18 sec
Reputation Power: 4
commonfile shell script

I am having trouble trying to figure out how to start this shell
script. Here are the instructions:

Write a program that will receive two command line parameters which are
paths to directories. Your program will do the following:

a) Verify that two parameters were passed in and that both of them
are paths to directories.

b) Determine if there are any common files (files with same name) in
the two directories and if so, print out the names of all common files.

Any help would be appreciated.

Reply With Quote
  #2  
Old November 8th, 2004, 02:31 PM
satyap satyap is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 210 satyap User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 49 sec
Reputation Power: 4
How to start the script?

path1=$1
path2=$2

:-)

(Hint: 'help [', 'man uniq')

Reply With Quote
  #3  
Old November 8th, 2004, 02:51 PM
miry2j miry2j is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 37 miry2j User rank is Private First Class (20 - 50 Reputation Level)miry2j User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 h 35 m 18 sec
Reputation Power: 4
Sorry should have been more specific. I am not sure how to compare files in two different directories and print them out.
Thanks.

Reply With Quote
  #4  
Old November 8th, 2004, 06:22 PM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 44 m 45 sec
Reputation Power: 9
#!/bin/sh
# quick+dirty
[ $# = 2 ] || exit 1
[ -d $1 ] || exit 1
[ -d $2 ] || exit 1
# using shell, you need tricks and temp-files
# because shell arrays are too expensive
find $1 >listONE
find $2 >listTWO
# this prints filenames common to both
comm -12 listONE listTWO
see man pages

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > commonfile shell script


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway