Skip to main content
code formatting, added missing semicolon
Source Link
Freddy
  • 26.3k
  • 1
  • 27
  • 64

I have the following command written to assign find results into an array, to delete files older than 7 days later. F_ARR[0]='' unset F_ARR find "$CDIR" ! -type d -mtime +7 -exec sh -c ' for pathname do F_ARR+=("$pathname") done ' sh {} + echo ${#F_ARR[@]} But

F_ARR[0]='' unset F_ARR find "$CDIR" ! -type d -mtime +7 -exec sh -c ' for pathname; do F_ARR+=("$pathname") done' sh {} + echo ${#F_ARR[@]} 

But, when I print the length of array F_ARR, it shows 0. Did I commit something wrong in code?

I have the following command written to assign find results into an array, to delete files older than 7 days later. F_ARR[0]='' unset F_ARR find "$CDIR" ! -type d -mtime +7 -exec sh -c ' for pathname do F_ARR+=("$pathname") done ' sh {} + echo ${#F_ARR[@]} But, when I print the length of array F_ARR, it shows 0. Did I commit something wrong in code?

I have the following command written to assign find results into an array, to delete files older than 7 days later.

F_ARR[0]='' unset F_ARR find "$CDIR" ! -type d -mtime +7 -exec sh -c ' for pathname; do F_ARR+=("$pathname") done' sh {} + echo ${#F_ARR[@]} 

But, when I print the length of array F_ARR, it shows 0. Did I commit something wrong in code?

Source Link

Unable to assign values to array within -exec command of find result

I have the following command written to assign find results into an array, to delete files older than 7 days later. F_ARR[0]='' unset F_ARR find "$CDIR" ! -type d -mtime +7 -exec sh -c ' for pathname do F_ARR+=("$pathname") done ' sh {} + echo ${#F_ARR[@]} But, when I print the length of array F_ARR, it shows 0. Did I commit something wrong in code?