If you have the full path of a file in a shell variable, say "$SOMEFILE",
you can take substrings from the variable by using sed, cut, awk, etc.
If you only want to take directory or file names from a full path, it's probably easier to use the "basename" or the "dirname" utility. See their man pages.
But the bash shell, can do some simple substrings itself. This is easier to learn, and it's faster. Some examples:
Code:
# asuming warcraft is a file, so there'll be no trailing '/'
SOMEFILE=/black/goodie/games/warcraft
# strip directory:
FILENAME=${SOMEFILE##*/}
# This means: Remove longest possible part ('##') from the
# beginning of variable SOMEFILE that matches the wildcard
# pattern ('*/').
# So FILENAME becomes the $SOMEFILE with all characters
# removed up to (and including) the last slash.
echo $FILENAME
# strip filename:
DIRNAME=${SOMEFILE%/*}
# This means: Remove the shortest possible part ('%') from the
# end that matches '/*'.
echo $DIRNAME
# Take a substring using character positions (zero based)
# This example takes out "goodie" from the path, by
# taking the substring of 6 characters, starting with character
# number 7:
TMP=${SOMEFILE:7:6}
echo $TMP