[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Understanding -X of compgen
From: |
Andy Chu |
Subject: |
Re: [Help-bash] Understanding -X of compgen |
Date: |
Sat, 23 Feb 2019 09:55:55 -0800 |
Three things:
1) The -f flag doesn't take an argument
2) compgen expects a positional argument, which can be empty for the current dir
3) -X removes the matches. To keep them, add ! as a prefix.
Try:
compgen -f -X '!*.sh' /tmp/
or equivalently
compgen -A file -X '!*.sh' /tmp/
Andy
On Sat, Feb 23, 2019 at 8:16 AM Peng Yu <address@hidden> wrote:
>
> Hi,
>
> I only want to keep files ending with `.sh`. But I don't quite
> understand how -X works. Could anybody show me how to use -X? Thanks.
>
> $ compgen -f /tmp/ -X '*.sh'
> /tmp/lG3BwsdIG9.date
> /tmp/lG3BwsdIG9.sh
>
> --
> Regards,
> Peng
>