0

Edit: I simply need to strip the .gz

SUBMIT joust_aallgeier_attempt_2015-11-12-20-37-40_project04.tar.gz

These are gunzipped already. I need project.tar output I have the following stripping the first portion.

filename=${j##*_}
Cyrus
  • 84,225
  • 14
  • 89
  • 153
M2bandit
  • 99
  • 1
  • 9
  • 1
    Can you give examples of files where it doesn't work? It looks like it should work. – Barmar Sep 22 '17 at 04:09
  • Sorry a logic issue had me blaming the wrong thing. I need to strip .gz from the end. – M2bandit Sep 22 '17 at 04:21
  • Holy jibbers I need to learn why " " is required on vars this is the second time I was beating me head against the wall for something like this not working. Thanks everyone. – M2bandit Sep 22 '17 at 04:36

1 Answers1

1

With bash's Parameter Expansion:

filename="SUBMIT joust_aallgeier_attempt_2015-11-12-20-37-40_project04.tar.gz"
stripped="${filename##*_}"
stripped="${stripped%.gz}"
echo "$stripped"

Output:

project04.tar
Cyrus
  • 84,225
  • 14
  • 89
  • 153