Apple - Cut in CLI doesn't work as expected - returns full lines every time
You can squeeze the white spaces into a single white space in ls
's output then use cut
.
ls -l /usr | tr -s ' ' | cut -d ' ' -f3
but avoid parsing ls
output. Here's an alternate solution.
stat -f'%Su' /usr/*
ls
doesn't use tabs, cut
doesn't work with a variable number of delimeters between fields.
ls -l /usr | awk '{print $3}'
will work, or
ls -l /usr | awk 'NR > 1 {print $3}'
if you want to skip the first line (total 0
in your example).