First, get file name without the path:
filename=$(basename -- "$fullfile")
extension="${filename##*.}"
filename="${filename%.*}"
Alternatively, you can focus on the last “https://stackoverflow.com/” of the path instead of the ‘.’ which should work even if you have unpredictable file extensions:
filename="${fullfile##*/}"
You may want to check the documentation :
- On the web at section “3.5.3 Shell Parameter Expansion“
- In the bash manpage at section called “Parameter Expansion”
Related Contents:
- How to convert a string to lower case in Bash
- How to loop over files in directory and change path and add suffix to filename
- How do I remove the file suffix and path portion from a path string in Bash?
- How to split one string into multiple strings separated by at least one space in bash shell?
- How to tell if a string is not defined in a Bash shell script
- How to rename with prefix/suffix?
- Renaming part of a filename [duplicate]
- In bash, how do I count the number of lines in a variable?
- How to remove files starting with double hyphen?
- How can I shortern my command line prompt’s current directory?
- Setting an environment variable before a command in Bash is not working for the second command in a pipe
- Exit Shell Script Based on Process Exit Code [duplicate]
- Copy files from one directory into an existing directory
- Reading a space-delimited string into an array in Bash
- Pass all variables from one shell script to another?
- Delete node_modules folder recursively from a specified path using command line
- Wait for a process to finish
- How can I select random files from a directory in bash?
- How to replace an entire line in a text file by line number
- How to silence output in a Bash script?
- How do I symlink all files from one directory to another in bash? [closed]
- Detect if homebrew package is installed
- Piping not working with echo command [duplicate]
- Equivalent of rm and mv in windows .cmd
- Bash scripting missing ‘]’ [closed]
- How do I test for an empty string in a Bash case statement?
- How do I timestamp every ping result?
- Script to get the HTTP status code of a list of urls?
- Why sudo cat gives a Permission denied but sudo vim works fine? [duplicate]
- find difference between two text files with one item per line [duplicate]
- Getting “sed error – illegal byte sequence” (in bash) [duplicate]
- Getting “command not found” error while comparing two strings in Bash
- access host’s ssh tunnel from docker container
- How to determine if a bash variable is empty?
- How do I get the current Unix time in milliseconds in Bash?
- Run an interactive bash subshell with initial commands without returning to the (“super”) shell immediately
- Checking if a ruby gem is installed from bash script
- gpg encrypt file without keyboard interaction [closed]
- What is the shortest way to get n-th column of an output?
- VSCode Integrated Terminal Doesn’t Load .bashrc or .bash_profile
- tr command – how to replace the string “\n” with an actual newline (\n)
- Differences between MSYS2 and Cygwin [closed]
- Why does Bash treat undefined variables as true in an ‘if’ statement?
- Bash script store command output into variable
- Check whether one number equals another number in Bash
- How do I create a directory on remote host if it doesn’t exist without ssh-ing in?
- what does ‘cd $_’ mean?
- How to print only the unique lines in BASH?
- how to detect a build error from ant/maven via a bash script?
- How to list files in directory using bash? [closed]