4

I am trying to find all my .txt and .csv files in my backup (Apple's time machine).

The structure of the backup directories is like this:

/machine name/date/Macintosh HD/ 

The above contains all the files from my machine on that day. I have many of those directories as the backup drive contains stuff from multiple machines, last 3 years.

What I am interested in is to find my text and CSV files so for example file:

/mac1/2014-08-31-173253/Macintosh HD/Users/me/Documents/work/file1.txt

So I need to find all .txt files which have somewhere on their path /Users/me

Hauke Laging
  • 88,146
  • 18
  • 125
  • 174
fluffy
  • 43
  • 3

2 Answers2

4

You could use find, provided it's available:

$ find "/mac1/2014-08-31-173253/Macintosh HD" -wholename "*/Users/me/*.txt" -or -wholename "*/Users/me/*.csv"

This will search /mac1/2014-08-31-173253/Macintosh HD for files containing the pattern */Users/me/*.(txt|csv) in their paths.

John WH Smith
  • 15,500
  • 6
  • 51
  • 62
-1

Probably you can just do:

set --
for d in /mac[123]/201[1-4]*'/Macintosh HD/Users/me/Documents/work/'
do  for g in .txt .csv
do  set -- "$d"*"$g"
    [ -e "$1" ] || shift
done

In that way you'd get an array of all of the file names in "$@" - but you'd need to glob the directory bit - which is what the /mac[123]/ is for, and I'm only guessing at the names of those directories.

mikeserv
  • 57,448
  • 9
  • 113
  • 229