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
Post a Comment