Skip to main content
deleted 12 characters in body
Source Link
music2myear
  • 43.2k
  • 50
  • 89
  • 129

My dear,

I think the most elegant way to remove multiple files type is using what is called brace expansion.

How does brace expansion work?

Brace expansion allows you to create multiple strings from patterns within a brace, where each pattern is separated by a comma. For instance, the command

echo Front-{A,B,C}-Back

will yield

Front-A-Back Front-B-Back Front-C-Back

Simple like that :) You can also expand a range of integers using the following notation

echo {001..15}

How to use brace expansion to solve your problem?

Try it:

tar --exclude={'*.jpg','*.png','*.bmp','*.gif'} -cvf tar-filename.tar folder

If you want to check out what is going on, just echo this last command and you will notice that it produces

tar --exclude=*.jpg --exclude=*.png --exclude=*.bmp --exclude=*.gif -cvf tar-filename.tar folder

Both ways are correct, but mine is much more readable and compact :)

My dear,

I think the most elegant way to remove multiple files type is using what is called brace expansion.

How does brace expansion work?

Brace expansion allows you to create multiple strings from patterns within a brace, where each pattern is separated by a comma. For instance, the command

echo Front-{A,B,C}-Back

will yield

Front-A-Back Front-B-Back Front-C-Back

Simple like that :) You can also expand a range of integers using the following notation

echo {001..15}

How to use brace expansion to solve your problem?

Try it:

tar --exclude={'*.jpg','*.png','*.bmp','*.gif'} -cvf tar-filename.tar folder

If you want to check out what is going on, just echo this last command and you will notice that it produces

tar --exclude=*.jpg --exclude=*.png --exclude=*.bmp --exclude=*.gif -cvf tar-filename.tar folder

Both ways are correct, but mine is much more readable and compact :)

I think the most elegant way to remove multiple files type is using what is called brace expansion.

How does brace expansion work?

Brace expansion allows you to create multiple strings from patterns within a brace, where each pattern is separated by a comma. For instance, the command

echo Front-{A,B,C}-Back

will yield

Front-A-Back Front-B-Back Front-C-Back

Simple like that :) You can also expand a range of integers using the following notation

echo {001..15}

How to use brace expansion to solve your problem?

Try it:

tar --exclude={'*.jpg','*.png','*.bmp','*.gif'} -cvf tar-filename.tar folder

If you want to check out what is going on, just echo this last command and you will notice that it produces

tar --exclude=*.jpg --exclude=*.png --exclude=*.bmp --exclude=*.gif -cvf tar-filename.tar folder

Both ways are correct, but mine is much more readable and compact :)

Source Link

My dear,

I think the most elegant way to remove multiple files type is using what is called brace expansion.

How does brace expansion work?

Brace expansion allows you to create multiple strings from patterns within a brace, where each pattern is separated by a comma. For instance, the command

echo Front-{A,B,C}-Back

will yield

Front-A-Back Front-B-Back Front-C-Back

Simple like that :) You can also expand a range of integers using the following notation

echo {001..15}

How to use brace expansion to solve your problem?

Try it:

tar --exclude={'*.jpg','*.png','*.bmp','*.gif'} -cvf tar-filename.tar folder

If you want to check out what is going on, just echo this last command and you will notice that it produces

tar --exclude=*.jpg --exclude=*.png --exclude=*.bmp --exclude=*.gif -cvf tar-filename.tar folder

Both ways are correct, but mine is much more readable and compact :)