scripting - Print full filenames with spaces in shell with find command -
I have a search command which is the size and file name of 20 largest files on the given directory (with full path) Will print and write it in a file:
$ $ {DIR} -type f -size + 1m -exec du -h '{}' + | Sort-hr | Awk '{print $ 1', '$ 2}' | Head-20> gt; & Gt; Files.csv
The problem is that there are some files present with the blank in your file name. These file names are printed only to the first place.
Ex: A file named 'Hello Thiext' is printed in the form of 'Hello'.
I have given the IFS 'N',
< Code> i.e.thanks
P>
awk
,print $ 1 "," $ 2
prints the first two regions separated by a comma. The problem is that there isthere.txt
inHello there.txt
in the third column.It seems that only
awk
is doing the first tab is changing with a comma, it can be easily done withsed
:$ find "$ {DIR}" -size f -size + 1m -exec du -h '{}' + | Sort-hr | Sed's / \ t /, / '| Head -20.0 m, / Path / hello there.txt
Comments
Post a Comment