This option works, but there are no hyphenation in the final file, all in one line. How to add hyphenation?

echo $(git ls-tree -r dev --name-only) > filesUnderGit.txt 

    2 answers 2

     git ls-tree -r master --name-only > test.txt 

    As with any other command that writes to stdout . And as with any such command, you can do a pipe-train, if you want to somehow handle the output stream.

     git ls-tree -r master --name-only | grep "some/path" | head 42 > test.txt 

    Here we take only the files lying in some/path , and then leave the first 42 of them.

      this design:

       $ echo $(git ...) 

      somewhat "overloaded."

      conditionally it can be represented as:

       $ ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ° $(ΠΊΠΎΠΌΠ°Π½Π΄Π°) 

      First, a ΠΊΠΎΠΌΠ°Π½Π΄Π° is executed that is enclosed within the β€œshell” (from the word shell , shell) operator $() .

      then its output (no matter if it contains one line or more) is converted to one line (line characters are replaced with spaces) to pass to the ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ΅ as a set of parameters (not options!).

      that's why it comes out "all in one line."

      in this particular case, such a conversion can be avoided quite simply - it is enough to remove echo and the $() operator - as unnecessary:

       $ ΠΊΠΎΠΌΠ°Π½Π΄Π° 

      but there can be such a situation as the program and the operator are needed, but it is required that there should be no β€œone-line conversion”. to avoid this is also not difficult - it is enough to put (double) quotes β€œin the way” between executing the $() operator and forming the parameter string for the ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΡ‹ . like that:

       $ ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ° "$(ΠΊΠΎΠΌΠ°Π½Π΄Π°)"