Sponsored Content
Top Forums Shell Programming and Scripting Simple directory tree diff script Post 302781823 by LMHmedchem on Monday 18th of March 2013 12:31:24 AM
Old 03-18-2013
I suspect that there is simply an issue with the reported size, since all of the file name match. For both partitions, they are windows ntfs, and the copy is smaller the the source. The copy was made using cp -Rfp under cygwin, so it may be that cp stored the copies more efficiently than they were stored in the original versions.

If I was to use the two sorted find files as a starting list for cmp, how would I differentiate the entries in the sorted list that are directories from those that are files? Since cmp is for files, will it just throw an exception if what you pass to it is a directory?

---------- Post updated 03-18-13 at 12:31 AM ---------- Previous update was 03-17-13 at 09:16 PM ----------

I have added the following to the end of my script to check each file pair with cmp. If I get this working, I will add logic to run this part based on an argument.
Code:
# further process sorted find list by checking each file pair with cmp
while read input
do
#  remove leading . from each line in find output
   TEMP=$(echo $input | sed 's/^.//g')
#  escape spaces
   LOCALFILE=$(echo $TEMP | sed 's/ /\\ /g')

   echo $TREE1$LOCALFILE
   echo $TREE2$LOCALFILE

   cmp $TREE1$LOCALFILE  $TREE2$LOCALFILE > $TMPDIR'/byte_compare.txt'

done < $TMPDIR'/check_1_sorted'

This uses one of the sorted find lists to identify each file. If the entry from find is a directory, is seems as if cmp just prints a notification to stderr and moves on. The problem I am having now is that cmp won't except what I have done above to escape the spaces in file names. I have done echo on the path for each file, and it appears correct, but I am getting an error from cmp,

/cygdrive/e/nlite/Presets/Last\ Session_u.ini
/cygdrive/i/nlite/Presets/Last\ Session_u.ini
cmp: invalid --ignore-initial value `/cygdrive/i/nlite/Presets/Last\'

cmp doesn't seem to be seeing anything past the escape. Am I not escaping this properly? If I don't escape the space, I get a similar error indicating that the space is breaking the input.

LMHmedchem
 

10 More Discussions You Might Find Interesting

1. Programming

directory as tree

hi i have modified a program to display directory entries recursively in a tree like form i need an output with the following guidelines: the prog displays the contents of the directory the directory contents are sorted before printing so that directories come before regular files if an entry... (2 Replies)
Discussion started by: anything2
2 Replies

2. Shell Programming and Scripting

directory tree

Hi all, The following is a script for displaying directory tree. D=${1:-`pwd`} (cd $D; pwd) find $D -type d -print | sort | sed -e "s,^$D,,"\ -e "/^$/d"\ -e "s,*/\(*\)$,\:-----\1,"\ -e "s,*/,: ,g" | more exit 0 I am trying to understand the above script.But... (3 Replies)
Discussion started by: ravi raj kumar
3 Replies

3. Shell Programming and Scripting

Diff. Backup Script Using TAR. Should be simple.

I'm specifically trying to find help or insight on using the --incremental ('-G') option for creating a tar. Please resist the urge to tell me to use --listed-incremental ('-g') option. That's fairly well documented in the GNU tar manual. GNU tar 1.19 This is what the manual does say in section... (0 Replies)
Discussion started by: protienplant
0 Replies

4. UNIX for Dummies Questions & Answers

Move all files in a directory tree to a signal directory?

Is this possible? Let me know If I need specify further on what I am trying to do- I just want to spare you the boring details of my personal file management. Thanks in advance- Brian- (2 Replies)
Discussion started by: briandanielz
2 Replies

5. Shell Programming and Scripting

Newbie problem with simple script to create a directory

script is: dirname= "$(date +%b%d)_$(date +%H%M)" mkdir $dirname should create a directory named Nov4_ Instead I get the following returned: root@dchs-pint-001:/=>./test1 ./test1: Nov04_0736: not found. Usage: mkdir Directory ... root@dchs-pint-001:/=> TOO easy, but what am I... (2 Replies)
Discussion started by: gwfay
2 Replies

6. UNIX for Dummies Questions & Answers

directory tree with directory size

find . -type d -print 2>/dev/null|awk '!/\.$/ {for (i=1;i<NF;i++){d=length($i);if ( d < 5 && i != 1 )d=5;printf("%"d"s","|")}print "---"$NF}' FS='/' Can someone explain how this works..?? How can i add directory size to be listed in the above command's output..?? (1 Reply)
Discussion started by: vikram3.r
1 Replies

7. UNIX for Dummies Questions & Answers

How to copy a tree of directory

Mi question is how can you copy only de three of directory and not the files in it. Only a need the three of directorys not the files (6 Replies)
Discussion started by: enkei17
6 Replies

8. Shell Programming and Scripting

Specific directory parsing in a directory tree

Hi friends, Hello again :) i got stuck in problem. Is there any way to get a special directory from directory tree? Here is my problm.." Suppose i have one fix directory structure "/abc/xyz/pqr/"(this will be fix).Under this directory structure i have some other directory and... (6 Replies)
Discussion started by: harpal singh
6 Replies

9. Shell Programming and Scripting

Shell script to build directory tree and files

Hi all, I'm trying at the moment to write a shell script to build a directory tree and create files within the built directories. I've scoured through sites and text books and I just can't figure out how to go about it. I would assume that I need to use loops of some sort, but I can't seem... (8 Replies)
Discussion started by: Libertad
8 Replies

10. Shell Programming and Scripting

How to run a script/command on all the directories in a directory tree?

How to run a script/command on all the directories in a directory tree? The below script is just for the files in a single directory, how to run it on all the directories in a directory tree? #!/bin/sh for audio_files in *.mp3 do outfile="${audio_files%.*}.aiff" sox "$audio_files"... (2 Replies)
Discussion started by: temp-usr
2 Replies
array-info(1)															     array-info(1)

NAME
array-info - check the status of a HP (Compaq) SmartArray controller SYNOPSIS
array-info -d array_device_path [-a|-l|-A|-c|-s|-L|-h] DESCRIPTION
Array-info is a command line tool to retrieve informations and logical drives status from several RAID controllers (currently HP Compaq IDA and CISS and MD). It displays informations about the firmware version, Rom revision, number of physical and logical drives on the con- troller, aswell as the fault tolerance, size, number of physical disks and status for each logical drive. OPTIONS
--device | -d Path to array device, e.g. /dev/ida/c0d0 or /dev/cciss/c0d1 --all-drives | -a Show informations about all drives --logical drive | -l Show informations about selected logical drive --show-ctrl | -c Show informations about controller --show-logical | -L Show informations about logical drives --show-physical | -p Show physical device informations --show-status | -s Show status of logical drives --show-all | -A Show all informations --version | -V Show version -h Show help about options COPYRIGHT
This manual page was written by Raphael Pinson <<raphink@ubuntu.com>>. Permission is granted to copy, distribute and/or modify this docu- ment under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation. 2006-12-15 array-info(1)
All times are GMT -4. The time now is 05:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy