0

I have the following Bash Script:

#!/bin/bash
cd ~/Library/Developer/CoreSimulator/Devices/;

files=$(find . -name iaGambro_gambro.sql)

select file in $files; do
    if [ -n "$files" ]; then
        sudo sqlite3 -header -column "${file}"
    fi
    break
done

It should return the following 2 results:

1) ./2EFF5EBF2B2D/Library/Private Documents/iaGambro_gambro.sql
2) ./A1AF3463BFD2/Library/Private Documents/iaGambro_gambro.sql

But it is is returning the following 4 because of the white space in Private Documents:

1) ./2EFF5EBF2B2D/Library/Private 
2) Documents/iaGambro_gambro.sql
3) ./A1AF3463BFD2/Library/Private 
4) Documents/iaGambro_gambro.sql

How do I get the select to recognize the paths with the spaces?

NOTE: I'm looking for how to execute on the given path, not just print it out

HalosGhost
  • 4,790

1 Answers1

1

You can use find ... -exec option:

find . -name iaGambro_gambro.sql -exec bash -c '
  select file do
    : Do something with "$file"
    break
  done
' bash {} +
cuonglm
  • 153,898