I have the following files
tcpdump-12
tcpdump-12.delay
tcpdump-24
tcpdump-24.delay
Is there a way to ls
only the files
tcpdump-12
tcpdump-24
I can do
ls tcpdump-[[:digit:]][[:digit:]]
but I am looking for something more generic that can take any number of digits, something like tcpdump-[0-9]+ if I was using vim or python regular expressions.
One needs to turn on extended glob functionality of bash to be able to use the advanced pattern matching.
$ ls
tcpdump-12 tcpdump-12.delay tcpdump-24 tcpdump-24.delay
$ shopt -s extglob
$ ls tcpdump-+([[:digit:]])
tcpdump-12 tcpdump-24
If you're sure that all the unwanted files end with '.delay' you can do this:
ls --ignore '*.delay'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With