-4

I have a big file which contains directories paths like below:

$PRJ/fp/t/mxl/lf/
$PRJ/fp/t/mxl/lf/

I want to read this file line by line and list out all the files inside each directory file in a line in output file.

I can use find command with directory path directory specify but how to use it with a file having directory paths is something I want. find input_file -type f does not work.

Shreya
  • 639
  • 4
  • 11

1 Answers1

2
while IFS= read -r dir; do
    find "$dir" -type f
done < <(envsubst < my_big_file)

See https://unix.stackexchange.com/a/294400/133219 and the man page for more info on envsubst.

Ed Morton
  • 188,023
  • 17
  • 78
  • 185
  • Interesting solution. I believe `$PRJ_WORK_DIR` should be set as an environmental variable for this to work. If that's not the case, `eval` is other more dangerous alternative. – r_31415 Aug 02 '22 at 22:02