Echo the basename in shell -


i have path directory , need extract filename out of can use further in shell script.

#!/bin/sh dir=/var/tmp/file1 fname= basename $dir  echo $fname echo "the script executes:" $fname  echo $fname 

here fname gets printed once. in other cases, comes blank.

where going wrong?

this below working.

#!/bin/sh dir=/var/tmp/file1 fname=`basename $dir` echo $fname echo "the script executes:" $fname echo $fname 

output $: ./tt.sh

file1

the script executes: file1

file1


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -