Getting the current filename using bash

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ cat ./testfilename.sh
#!/bin/bash
fullfile=`basename $0`
filename=$(basename "$fullfile")
echo "filename:"$filename
extension="${filename##*.}"
echo "extension:"$extension
justfilename="${filename%.*}"
echo "justfilename:"$justfilename


$ ./testfilename.sh
filename:testfilename.sh
extension:sh
justfilename:testfilename
This entry was posted in Linux, Operating System. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


+ 9 = eighteen