Sponsored Content
Top Forums Shell Programming and Scripting Compare two folders and file content Post 302921791 by ongoto on Monday 20th of October 2014 10:48:25 AM
Old 10-20-2014
Is this anything close to what you want?
Code:
log0=/tmp/changes.log

diff -r <(ls -1 $1 | sort)  <(ls -1 $2 | sort) > /tmp/junk0

if [ ! -z /tmp/junk0 ]; then
    >$log0
    printf "Dirs %s and %s differ\n" $1 $2 > $log0
    echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $log0

    while read buf
    do
        if [[ ${buf:0:1} == '<' ]]; then
            printf "%s.log: File added: %s\n" $1 ${buf##*<} >> $log0
        elif [[ ${buf:0:1} == '>' ]]; then
            printf "%s.log: File added: %s\n" $2 ${buf##*>} >> $log0
        fi
    done < /tmp/junk0
fi

cat $log0
# rm  /tmp/junk0 $log0


Last edited by ongoto; 10-20-2014 at 12:16 PM.. Reason: forgot >> $log0
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remote compare of folders

Hi, Is there a way (either commands/tools/scripts/logic) to compare two given folders on different unix boxes. I want to compare folder a in Unix box 'A' with folder 'b' in Unix box 'B'. I can run the script in Unix box 'A'. I am looking. for following results: files/sub folders only in a... (1 Reply)
Discussion started by: sunilav
1 Replies

2. Shell Programming and Scripting

To Compare content of one file with other file

Hi All, I need to compare the content of one file with the other.The first file holds the records: aaa ,123 bbb,321 ccc,890 Second file willl holds the record aaa,bbb,ccc My problem is i need to take the first column of file one and compare with the first row of second file.If it... (1 Reply)
Discussion started by: ithirak17
1 Replies

3. UNIX for Dummies Questions & Answers

To compare selective file in different folders

Hello, I am using dircmp -d <folde1> <Folder2> to compare the files from two different foldes, but this command compares for all the files. Is there any option to select only some files for comparision. For example in Folder1: file1.txt file2.txt file3.txt Folder2 file1.txt file2.txt... (0 Replies)
Discussion started by: gmahesh2k
0 Replies

4. Shell Programming and Scripting

Compare 2 folders...

Hello, I try to compare 2 folders, i explain, i have file in this 2 folder and i want to print out the difference in this folders... ex: folder1: file1 file2 file3 folder2: file1 file2 print file3 I do a ls of the 2 folders and i use the command diff (diff $var1 $var2) without... (8 Replies)
Discussion started by: protocomm
8 Replies

5. Shell Programming and Scripting

split file content into specific folders

Hi I have a large text file and I want to split its content into multiple flies. this large file contains several blocks of codes separated by a comment line for each block. this comment line represents a directory path So, when separate these blocks each into a separate file, This output... (7 Replies)
Discussion started by: turki_00
7 Replies

6. Shell Programming and Scripting

Bash selective copy folders and content to another location

I'm looking for a bash scrypt to copy some folders and some of the content to another location. I'm a teacher and very noobish with programming language anyway what I'm looking for , I have this director structure Main director "Students" with subfolders "john";"daisy";"work" etc .. and some of... (2 Replies)
Discussion started by: brickleul
2 Replies

7. Shell Programming and Scripting

Ksh: how compare content of a file with an other array

Hi, I created a skript in ksh which generate a file with semicolon as separator, this is an example of the file a created: example content file: hello;AAAA;2014-08-17 hello;BBBB;2014-08-17 hello;CCCC;2014-08-17 I would need to compare the content in of the second column of this file... (3 Replies)
Discussion started by: jmartin
3 Replies

8. Shell Programming and Scripting

Move multiple files 4rm Source to different target folders based on a series num in the file content

Dear Experts my scenario is as follows... I have one source folder "Source" and 2 target folders "Target_123456" & "Target_789101". I have 2 series of files. 123456 series and 789101 series. Each series has got 3 types of fiels "Debit", "Refund", "Claims". All files are getting... (17 Replies)
Discussion started by: phani333
17 Replies

9. Shell Programming and Scripting

Compare & print content of file which is not matching

Hi All I want to compare 2 files using awk and get output of content which is not matching I have 2 files a.txt 123 456 780 143 b.txt A|B|C|167|D|E C|K|D|123|D|E A|B|D|789|G|F C|D|G|143|A|B Not matching line from b.txt O/P A|B|C|167|D|E A|B|D|789|G|F (3 Replies)
Discussion started by: aaysa123
3 Replies

10. Shell Programming and Scripting

Script to compare files in 2 folders and delete the large file

Hello, my first thread here. I've been searching and fiddling around for about a week and I cannot find a solution.:confused: I have been converting all of my home videos to HEVC and sometimes the files end up smaller and sometimes they don't. I am currently comparing all the video files... (5 Replies)
Discussion started by: Josh52180
5 Replies
LIBXO(3)						   BSD Library Functions Manual 						  LIBXO(3)

NAME
xo_emit -- emit formatted output based on format string and arguments LIBRARY
library ``libxo'' SYNOPSIS
#include <libxo/xo.h> int xo_attr(const char *name, const char *fmt, ...); int xo_attr_h(xo_handle_t *handle, const char *name, const char *fmt, ...); int xo_attr_hv(xo_handle_t *handle, const char *name, const char *fmt, va_list vap); DESCRIPTION
The xo_attr() function emits attributes for the XML output style. The attribute value is recorded in the handle and is attached to the next field that is emitted via a xo_emit(3) call. The name parameter give the name of the attribute to be encoded. The fmt parameter gives a printf-style format string used to format the value of the attribute using any remaining arguments, or the vap parameter as passed to xo_attr_hv(). EXAMPLE: xo_attr("seconds", "%ld", (unsigned long) login_time); struct tm *tmp = localtime(login_time); strftime(buf, sizeof(buf), "%R", tmp); xo_emit("Logged in at {:login-time} ", buf); XML: <login-time seconds="1408336270">00:14</login-time> Since attributes are only emitted in XML, their use should be limited to meta-data and additional or redundant representations of data already emitted in other form. ADDITIONAL DOCUMENTATION
Complete documentation can be found on github: http://juniper.github.io/libxo/libxo-manual.html libxo lives on github as: https://github.com/Juniper/libxo The latest release of libxo is available at: https://github.com/Juniper/libxo/releases SEE ALSO
xo_emit(3) HISTORY
The libxo library was added in FreeBSD 11.0. AUTHOR
Phil Shafer BSD
June 3, 2019 BSD
All times are GMT -4. The time now is 02:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy