i have been asked to write a bash shell script comparing two directories and sed or awk should not be used in this assignment. compdir will compare filenames in two directories, and list information about filenames that are in one directory but not the other. The information listed will be a long listing of each file, similar to the "ls -l" command. The directory names must be specified, including any required absolute or relative paths.
compdir will work for all kinds of files, including directories that are contained in the specified directories. The script will print an appropriate error message if the number of arguments passed to it is something other than 2, or if the directory names specified are not names of valid existing directories. If an error message is issued, then the script should end with an exit status of 1 (one). Otherwise, it should end with an exit status of 0 (zero).
Here are examples of compdir error messages (directory d1 exists, d2 and d3 do not exist):
anyone has any tips on how i should do this. im a begginer in scripting. thanks.
Last edited by pludi; 11-03-2009 at 06:33 PM..
Reason: code tags, please...
Hello, this is my first post here.
I'm attempting to write a bash shell script to rm the contents of a directory without deleting the directory, specifically in OS X 10.10 . Here's what I have:
function clear() {
USER="$USER"
DIR=$1
rm -rfv /Users/"$USER"/library/$DIR/*
}
clear... (6 Replies)
Here is my dir structure:
/tmp/dave/myappend.txt
/tmp/dave/dir1/test.txt
/tmp/dave/dir2/test.txt
/tmp/dave/dir3/test.txt
/tmp/dave/dir4/test.txt
I want to append the contents of myappend.txt to the end of each file with the name "test.txt" in all dirs in /tmp/dave/
I have tried this:... (2 Replies)
Hello,
I have two files containing both two columns:
$ cat file1
col1 nbr1
col2 nbr2
col3 nbr3
...
$ cat file2
val1 ri1
val2 ri2
val3 ri3
...
I need to compare every nbr (nbr1, nbr2,...) in the second column of file1 with every ri (ri1, ri2,...) in the second column of... (5 Replies)
Give shell script....which takes two file names as input and compares the contents, is both are same delete second file's contents.....
I try with "diff"...... but confusion how to use "diff" with if ---else
Thanking you (5 Replies)
I use diff -r dir1 dir2 to get comparison of two folders that are on same machine.
Now I need the same thing but one of the folders is on a different machine.
Currently I ftp the folder to a temp folder compare using above command and delete the temp folder.
Is there any other better options?... (5 Replies)
I am new to shell programming and have an assignment question which requires me to list the contents of the present working directory in 4 column format and highlight any subdirectories. It then requires me to develop the shell script to accept a directory name as a positional parameter (if no... (1 Reply)
I have been trying to find the answer to this but can't seem to get it.
I have two rows, both are CSV files.
I want to iteratively compare each field value to the corresponding value in the second file.
Example:
File 1.txt
1|hello|3.2|AMB||||B
File 2.txt
1|hi|3,2|ABC||||C
The... (1 Reply)
What would the best scripting language be for selecting all the directories in the current directory that are over a week old and deleting there contents?
Perl? bash? groovy? ruby? something else? How would you do it? I got a start with perl in the beginners@perl.org and I started to think:... (3 Replies)
I have an array "arrA" with the following contents:
A0012 Paint Shop.doc
ES001 Contract Signature.doc
Budget Plan.pdf
TS PWS.pdf
My data file "Files.dat" has the same contents:
A0012 Paint Shop.doc
ES001 Contract Signature.doc
Budget Plan.pdf
TS PWS.pdf
I have a script that compares... (0 Replies)