if [[ $1 == *.(png|jpg) ]]
is what I've tried, and it doesn't work. I need to check if $1
matches one of those filename suffixes, so I can then do stuff with it. I'm not sure how to go about this. I'm just getting into bash
. I've searched all through these forums, and others. I have yet to find something that works for a conditional if
statement.
FILE
on each file to determine its type then categorize them from there? Or is this solution fine? – memespace Mar 25 '21 at 16:33mv foo.jpg foo.png
, the suffix doesn't match the contents, which might confuse some programs. But it's still by far the most widely used way for telling the file type (I guess you could use extended attributes or such, but they're not portable.) And knowing the file type before trying to interpret it is just useful, in the least it saves time. Also, if you have the same file in different formats, you'd need to figure out some other way to tell the files apart (thinkprog.c
,prog.o
andprog
; orsomedoc.odt
,somedoc.pdf
etc.) – ilkkachu Mar 25 '21 at 16:38