Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash get file name

# Basic syntax:
basename $YOURFILE

# Example usage:
YOURFILE="/path/to/your_file.txt"
basename $YOURFILE
--> your_file.txt

# Note, to remove a specified suffix from the file name, add it at the end like:
basename $YOURFILE .txt
--> your_file

# Note, to run basename in a bash script and assign the output to a variable,
# use the following syntax:
FILENAME="$(basename -- $YOURFILE)"
Source by www.cyberciti.biz #
 
PREVIOUS NEXT
Tagged: #bash #file
ADD COMMENT
Topic
Name
3+1 =