|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
How to start the script?
path1=$1 path2=$2 :-) (Hint: 'help [', 'man uniq') |
|
#3
|
|||
|
|||
|
Sorry should have been more specific. I am not sure how to compare files in two different directories and print them out.
Thanks. |
|
#4
|
|||
|
|||
|
#!/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 |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > commonfile shell script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|