views:

238

answers:

2

hi folks,

the bash auto completion make a / at the end of a directory how i can strip this out?

Thanks for hints.

#!/bin/sh

target=$1

function backup(){
  date=`date "+%y%m%d_%H%M%S"`
  PWD=`pwd`
  path=$PWD/$target
  tar czf /tmp/$date$target.tar.gz $path
}

backup
+5  A: 

Use

target=${1%/}

A reference.

martin clayton
Thanks, it works.
Burntime
+5  A: 

Use target=${1%/}

See this the parameter substitution of this bash scripting guide for more.

Gregory Pakosz