Simulate -print0 with ls
Posted 09-07-2011 at 04:39 AM by sag47
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.
find . -type f -print0 | xargs -0 somecommand
ls -m | sed 's/, /\x0/g' | xargs -0 somecommand
find . -maxdepth 1 -type f -print0 | xargs -0 somecommand
Total Comments 0