Visit The New, Modern Unix Linux Community

Diff - filename and directory name are same

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Diff - filename and directory name are same
# 1  
Diff - filename and directory name are same


I have in the one folder file and directory that have same name. I need make diff from first directory where exists file in folder FOLDER/filename and second file where not exist folder, but FOLDER is filename. I use -N switch for create new file. Scripts report: Not a directory

diff -u -N a/FOLDER/filename b/FOLDER/filename

in a: filename is in the FOLDER
in b: directory FOLDER not exist, but exists file with name FOLDER

How I can remove this problem ?
# 2  
I don' t think you can have in the same path a file and a directory with the same name. Capital letters? Spaces/white characters? Please cd to the directory where they are, and post output of
ls -il

ls *  -d | tr ' |\t' '+'

to look at the file/dir closer. The second command will display the dir/filenames with space or tab replaced with '+'.

Last edited by mirni; 03-13-2011 at 09:30 PM..
# 3  
Aha, I just learned -F option of ls. this can solve your problem.
assume you have directories a and b.
do this:

cd a/ && find ./ |xargs ls -Fd >/tmp/dirA
cd b/ && find ./ |xargs ls -Fd >/tmp/dirB

then, you may want to sort the two file and diff.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #982
Difficulty: Medium
NetBSD is a free and open-source Unix-like operating system based on the Berkeley Software Distribution (BSD).
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Simple directory tree diff script

I have had some issues with a data drive and have copied all of the data to a new drive. The size used is not the same on both drives with a 3GB difference (less on the new drive). There are millions of files on the data drive, so it is not an easy task to determine if there are some files missing... (17 Replies)
Discussion started by: LMHmedchem
17 Replies

2. Shell Programming and Scripting

Diff between grep .* file name and grep '.*' filename

Hi, Can anyone let me know what is difference between grep .* foo.c grep '.*' foo.c I am not able to understand what is exact difference. Thanks in advance (2 Replies)
Discussion started by: SasDutta
2 Replies

3. Shell Programming and Scripting

serach diff filename in diff location using shell scripting

Hi, I am new to shell scripting. please help me to find out the solution. I need a script where we need to read the text file(consists of all file names) and get the file names one by one and append the date suffix for each file name as 'yyyymmdd' . Then search each file if exists... (1 Reply)
Discussion started by: Lucky123
1 Replies

4. Shell Programming and Scripting

Checking whether the file exists under a directory and doing a diff

Hi Everyone, I am writing a shell script for the below needs and would like your suggestions and advices. I have a lot of scripting files(Shell Scripts) under the directory: /home/risk_dev/dev I have another directory which has a lot of shell scripts under the directory: ... (2 Replies)
Discussion started by: filter
2 Replies

5. Red Hat

compare/diff two directory in two different linux/unix machine

Hi, I have two server , one linux and one unix . I want to compare two different directry in them . What command or tool I can use instead of search the dir one by one ??? thank (3 Replies)
Discussion started by: chuikingman
3 Replies

6. Shell Programming and Scripting

Best way to diff two huge directory trees

Hi I have a job that will be running nightly incremental backsup of a large directory tree. I did the initial backup, now I want to write a script to verify that all the files were transferred correctly. I did something like this which works in principle on small trees: diff -r -q... (6 Replies)
Discussion started by: same1290
6 Replies

7. Shell Programming and Scripting

how to get filename from directory

hi find /home -type f -atime +5 shows me files like : home/test/aaa.txt home/test/bbb.html How can I get the file name I mean only aaa.txt and bbb.html (19 Replies)
Discussion started by: tjay83
19 Replies

8. UNIX and Linux Applications

svn diff failed (no such file or directory)

I'm on ubuntu fiesty using svn as version control and gvim as my IDE. i like to review changes to files before checking them in. at some point in my life i used " svn diff {path}/{filename} " this now returns Index: {path}/{file}... (5 Replies)
Discussion started by: manic
5 Replies

9. Shell Programming and Scripting

Need quick help with diff files in current directory!!!

i have a problem that needs to be solved with CSH , SED or AWK as soon as possible. I need to write a program which creates a directory called backup (if it does not exist). The program then compares all the ordinary files in the current directory and if two files are identical, it moves one of... (1 Reply)
Discussion started by: tkwai
1 Replies

10. Shell Programming and Scripting

how to look in directory for files with diff date

What kind of command can i use to search a directory and subdirectories for all files that do not have the same date? i want to find any files that do not match a date of Sep 13, 2002? Or that have a different owner or group? Any help appreciated! (2 Replies)
Discussion started by: kymberm
2 Replies

Featured Tech Videos