0

I need to test wc with --files0-from=F flag, but I don't know how to write a file that contains NUL-terminated file names? Whatever I try, it merges the file names together and outputs:

wc: '1.txt2.txt': No such file or directory
wc: '1.txt 2.txt': No such file or directory
wc: '1.txt\02.txt': No such file or directory

How do I write the NUL-terminator?

ivanacorovic
  • 2,669
  • 4
  • 30
  • 46

2 Answers2

2

Apparently you can't. NUL-terminated filenames are the output of another program. What I did is put all the files I need in one folder, then execute this command there:

find * -print0 > feed.txt

So feed.txt now has file names separated by NUL character, which is what I need to execute this successfully.

wc --files0-from=feed.txt
ivanacorovic
  • 2,669
  • 4
  • 30
  • 46
1

Yes I have test the way @ivanacorovic said and it works.

-print0 is must, and -print does not work.


BTW.
Refer to this question, I have found the way to type out NUL-terminated NUL.
^@ is NUL, however it is not the combination of @and ^. The right way to type it is:
Ctrl+v followed by Ctrl+Shift+@
Actually you can see the ^@ through vim by -print0 option.

Leo
  • 33
  • 5