11311

Find missing numbers in continuous filenames (advanced ls & find)

Question:

Let's say I have a script that generates incrementing folder names over time (100, 101, 102, 103, 104, etc...). These folders are synced between machines and there is a chance of creation failure for any given folder on system 2.

System 1 is always in sync: 100/ 101/ 102/ 103/ 104/ etc...

System 2 may have errors: 100/ 102/ 103/ etc...

(as you can see, 101/ & 104/ are missing on system 2)

<strong>How can I generate a list of all the missing folders on System 2?</strong>

P.S. Rsync is not really an option because the actual number of folders is incredibly high.

Answer1:

You can pipe the contents of ls on each machine to a file, and then diff the two files. You can also use the command comm to show lines that are only in one file, and not in the other.

Answer2:

You could do something like this:

% ls -1 System1 > ls.System1 # Use the -1 flag to ensure 1 dir per line % ls -1 System2 > ls.System2 % comm -23 ls.System1 ls.System2 101 104

The comm command can show you what is common to both, unique to f1, or unique to f2:

comm -12 f1 f2 # common to both comm -23 f1 f2 # unique to f1 comm -13 f1 f2 # unique to f2

Answer3:

just generate a list of successful creations as they occur

Answer4:

you can use diff. assuming you had already mapped system2 to a path

diff system1/path system2/path

Recommend

  • Ways to synch many (small) files over high-latency network connection
  • git installation needed on remote server which is access via ssh only
  • Deploy subdirectory with mina
  • gulp: passing dependent task return stream as parameter
  • readyRead() signal of QextSerialPort (QIODevice) is not being called fast enough
  • Git cherry-Pick a batch of commits from a file
  • console.log printing statements in the wrong order for learnyounode node.js tutorial
  • Determining the length of a read stream in node js
  • WP7 difficulties binding data to listbox itemssource - won't refresh
  • java.lang.IndexOutOfBoundsException occuring on ArrayList
  • Ruby 1.8.6 Array#uniq not removing duplicate hashes
  • Synchronize windows folders
  • Configure Spring's MappingJacksonHttpMessageConverter
  • How to read piped content in C?
  • AppleScript : find open tab in safari by name and open it
  • SetWindowsHookEx does not react on media keys
  • How to revert to previous XCode version?
  • How do I access an unhandled exception in an MVC Error view?
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • Google Custom Search with transparent background
  • Update CALayer sublayers immediately
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • Where to put my custom functions in Wordpress?
  • vba code to select only visible cells in specific column except heading
  • Build own AppleScript numerical error handling
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Numpy divide by zero. Why?
  • Circular dependency while pushing http interceptor
  • Linker errors when using intrinsic function via function pointer
  • Why joiner is not used after Sequence generator or Update statergy
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • File not found error Google Drive API
  • Turn off referential integrity in Derby? is it possible?
  • Add sale price programmatically to product variations
  • Is it possible to post an object from jquery to bottle.py?
  • Unable to use reactive element in my shiny app
  • Android Heatmap on canvas or ImageView
  • To Get the radio button value in ruby on rails
  • How do I use LINQ to get all the Items that have a particular SubItem?