Simulate -print0 with ls
Posted 09-07-2011 at 03:39 AM by sag47
Tags find
Recently I wanted to manipulate files only in the current directory (not sub-directories). I usually use the following combination...
The only problem I had with that was it ran through all sub-directories as well. Then I remembered the -m switch for ls and decided to depend on my good old friend sed.
Though I guess it would be better to do it like so...
So many ways to do it and I'm just playing around.
SAM
Code:
find . -type f -print0 | xargs -0 somecommand
Code:
ls -m | sed 's/, /\x0/g' | xargs -0 somecommand
Code:
find . -maxdepth 1 -type f -print0 | xargs -0 somecommand
SAM
Total Comments 0