![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Permission Reset? | coopns | OS X (Apple) | 3 | 11-12-2008 03:45 PM |
| How to convert byteArray variables to HexaString variables for Linux? | ritesh_163 | High Level Programming | 2 | 08-11-2008 12:55 AM |
| I would like to reset my password | matrixmadhan | Post Here to Contact Site Administrators and Moderators | 5 | 04-30-2007 11:46 PM |
| How Do I Reset An Ssh Port | PCTECH | UNIX for Dummies Questions & Answers | 3 | 01-04-2005 05:57 PM |
| System Reset | s_aamir | UNIX for Advanced & Expert Users | 2 | 03-11-2002 05:15 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to check & reset variables
Hi, I'm dealing with a small problem here that I can't seem to overcome by myself. Any help would be greatly appreciated ![]() Basically, I have three variables, EXTSUB1, EXTSUB2 and EXTSUB3. These variables carry a file the user provides. What I need is to check each of the variables and if the specific variables carries a file with a specific extension, then reset that variable. I currently have the following but would like to reduce this code, maybe even do it in one go for all three variables... Code:
# Check file extensions and if they match the
# defined ones, reset the specific variable
case "${EXTSUB1##*.}" in
ass|ASS|idx|IDX|sub|SUB|sup|SUP|ssa|SSA)
echo
echo "-> Subtitle format '${EXTSUB1##*.}' not supported!"
echo "-> Skipping import..."
EXTSUB1=
;;
esac
case "${EXTSUB2##*.}" in
ass|ASS|idx|IDX|sub|SUB|sup|SUP|ssa|SSA)
echo
echo "-> Subtitle format '${EXTSUB2##*.}' not supported!"
echo "-> Skipping import..."
EXTSUB2=
;;
esac
case "${EXTSUB3##*.}" in
ass|ASS|idx|IDX|sub|SUB|sup|SUP|ssa|SSA)
echo
echo "-> Subtitle format '${EXTSUB3##*.}' not supported!"
echo "-> Skipping import..."
EXTSUB3=
;;
esac
Any better way of doing this with smaller code? Thanks ----------------------------------- OK, so I found away to use arrays for the job... Currently I have the following and it seems to work after some testing. Code:
for i in {1..3}; do
if [ ! -z "${EXTSUB[$i]}" ]; then
case "${EXTSUB[$i]##*.}" in
idx|IDX|sub|SUB|sup|SUP|ass|ASS|SSA|SSA|ttxt|TTXT)
echo
echo "-> Subtitle format '$(echo ${EXTSUB[$i]##*.} | tr '[:lower:]' '[:upper:]')' not supported by OGM!"
echo "-> Skipping import of '${EXTSUB[$i]}'"
EXTSUB[$i]=
;;
esac
fi
done
Last edited by mutex1; 06-17-2009 at 03:01 PM.. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|