Skip to main content
added 606 characters in body
Source Link
jw013
  • 52.9k
  • 11
  • 143
  • 142
rm sequence_1*.hmf

removes files beginning with sequence_1 and ending with .hmf.


Globbing is the process in which your shell takes a pattern and expands it into a list of filenames matching that pattern. Do not confuse it with regular expressions, which is different. If you spend most of your time in bash, the Wooledge Wiki has a good page on globbing (pathname expansion). If you want maximum portability, you'll want to read the POSIX spec on pattern matching as well / instead.


In the unlikely case you run into an "Argument list too long" error, you can take a look at [BashFAQ 95](http://mywiki.wooledge.org/BashFAQ/095 "I'm getting "Argument list too long". How can I process a large list in chunks?"), which addresses this. The simplest workaround is to break up the glob pattern into multiple smaller chunks, until the error goes away. In your case, you could probably get away with splitting the match by prefix digits 0 through 9, as follows:

for c in {0..9}; do rm sequence_1_"$c"*.hmf; done
rm sequence_1*.hmf  # catch-all case
rm sequence_1*.hmf

removes files beginning with sequence_1 and ending with .hmf.


Globbing is the process in which your shell takes a pattern and expands it into a list of filenames matching that pattern. Do not confuse it with regular expressions, which is different. If you spend most of your time in bash, the Wooledge Wiki has a good page on globbing (pathname expansion). If you want maximum portability, you'll want to read the POSIX spec as well / instead.

rm sequence_1*.hmf

removes files beginning with sequence_1 and ending with .hmf.


Globbing is the process in which your shell takes a pattern and expands it into a list of filenames matching that pattern. Do not confuse it with regular expressions, which is different. If you spend most of your time in bash, the Wooledge Wiki has a good page on globbing (pathname expansion). If you want maximum portability, you'll want to read the POSIX spec on pattern matching as well / instead.


In the unlikely case you run into an "Argument list too long" error, you can take a look at [BashFAQ 95](http://mywiki.wooledge.org/BashFAQ/095 "I'm getting "Argument list too long". How can I process a large list in chunks?"), which addresses this. The simplest workaround is to break up the glob pattern into multiple smaller chunks, until the error goes away. In your case, you could probably get away with splitting the match by prefix digits 0 through 9, as follows:

for c in {0..9}; do rm sequence_1_"$c"*.hmf; done
rm sequence_1*.hmf  # catch-all case
Source Link
jw013
  • 52.9k
  • 11
  • 143
  • 142

rm sequence_1*.hmf

removes files beginning with sequence_1 and ending with .hmf.


Globbing is the process in which your shell takes a pattern and expands it into a list of filenames matching that pattern. Do not confuse it with regular expressions, which is different. If you spend most of your time in bash, the Wooledge Wiki has a good page on globbing (pathname expansion). If you want maximum portability, you'll want to read the POSIX spec as well / instead.