-1

Ok, to be clear, this is a school assignment, and I don't need the entire code. The problem is this: I use

set subory = ("$subory:q" `sh -c "find '$cesta' -type f 2> /dev/null"`)

to fill variable subory with all ordinary files in specified path. Then I have a foreach where I count lines of all files in a directory, that's not the problem. Problem is, that when this script is tested, some big directories are use as the path. What happens is that the script doesn't finish, but gives error message word too long. That word is subory. This is a real problem, because $cesta can be an element of a long list of paths. I tried, but I cannot solve this problem. Any ideas? I'm a bit lost.

EDIT: To be clear, the task is to assign each directory a number, that represents the total line count of all it's files, and then pick the directory with greatest number.

Slaaavo
  • 112
  • 1
  • 11

1 Answers1

0

You need to reorganize your code. For example:

find "$cesta" -type f -execdir wc -l {} +

This will run wc on all the files found, without ever running afoul of command line-length limitations, "invalid" characters like newlines in filenames, etc. And you don't need to spawn a new shell to do it.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436