3

I want to extract only a specific file type using unrar.

With unzip command I can extract all archives with a specific extension.

unzip "$FileName" *[.txt,.TXT]

How can I do the same with unrar? Do I need to iterate through every file?

4
  • 1
    unrar "$FileName" '*.txt' Commented Jun 29, 2016 at 4:22
  • @SatoKatsura Does it work for both types? Some people capitalize extensions. I guess for now I'll lower-case the extension variable. Commented Jul 1, 2016 at 5:47
  • 1
    There are switches to change names to lower or upper case. Maybe they are applied before matching. Commented Jul 1, 2016 at 5:50
  • I guess it's better to lower-case if I want to extract multiple formats. Thanks Commented Jul 1, 2016 at 17:30

1 Answer 1

3
unrar x "$FileName" \*.txt \*.TXT

In bash you can also use:

unrar x "$FileName" \*.{txt,TXT}

Bash transforms this to the former form.

1
  • Just what I was looking for. I give my thanks cheers Commented Jun 13, 2018 at 21:27

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.