I'd like to limit output of find command. In the past I used to use for this ls command, e.g:
ls *tgz|head -100|xargs -i mv "{}" ../
but I got to know that the result may be unpredictable if name of file contains new line character. So more correct way to do this is something like that:
find ... -print0 | xargs -0
But taking this approach I'm not able to limit output of find with head command - it shows all file names separated with ^@ special sign:
find . -name '*tgz' -print0|head -2|less
file1.tgz^@file2.tgz^@file3.tgz^@file4.tgz^@file5.tgz^@
Is there a method to work this awkwardness away?
I tried to resolve it with help of awk:
find . -name 'BATCHED*' -print0|awk 'BEGIN{RS=""}'
but it still displays either all or zero lines.
May it be solved with help of awk? Is there better solution?
BTW. I found this very instructive reference but there is not answer on my question.
done 9< <( find /full/path -print0 )mean in this context? I'm used to application ofdone < "Filename"pattern, but I don't know this one. Thank you in advance. – szamasz Mar 07 '12 at 13:57cat/ssh) without worrying about your loop terminating after the first file because the whole stream was swallowed. – l0b0 Mar 07 '12 at 14:32