How to list a directory "all except"
Brian Cluff
brian at snaptek.com
Wed Aug 7 09:11:26 MST 2013
A few more just to mix it up a bit.
Delete lines from ls output that have htm at the end
ls -ltr |sed '/\.htm$/d'
You can also use perl, the swiss army club:
ls -l |perl -n -e 'print unless /\.htm$/'
This one might be the most efficient of the bunch, since it's all in one
command:
find -not -iname "*.pdf" -printf "%M %2n %u %g %8s %Cb %Cd %CY %f\n"
This is a cool one that is bash specific, but it only works on the
current directory:
shopt -s extglob
ls -lt !(*.htm)
Brian Cluff
On 08/07/2013 08:04 AM, joe at actionline.com wrote:
> What syntax would one use to list all the contents
> of a directory *except* those of a specified criteria?
>
> For example, I know that: ls -ltr *htm
> lists all contents ending in 'htm'
>
> But how could I list all contents excluding those ending in 'htm'?
>
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
More information about the PLUG-discuss
mailing list