help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why compgen -f of bash completion showing all


From: Greg Wooledge
Subject: Re: why compgen -f of bash completion showing all
Date: Mon, 4 Sep 2023 10:48:46 -0400

On Mon, Sep 04, 2023 at 09:19:02PM +0700, Budi wrote:
> Why
> 
> $ compgen -f
> 
> 
> show every object exists in PWD,  not only file ?

Because everything in the file system is a file.

> How to do to get the desire of getting file only

You mean "regular files", I assume.  Loop over the results, and apply
[[ -f ]] or test -f to each file, to see which files are regular files,
and which are not.

Since you're looping anyway, you might as well use * instead of
compgen.  It'll be easier and probably more efficient.  (Note, you
may want shopt -s dotglob.)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]