views:

23

answers:

2

I am working on a Bash shell script that does something like this:

#!/bin/bash

folder=/mnt

mkdir $folder/folder-`date +%N`

var1=

Now i need to somehow get the full path for the newly created folder into var1. There is going to be created a lot of folders in /mnt so i need to be 100% sure that the path in var1 is pointing to precisely the folder created in the previous line.

+1  A: 

Define var1 before creating the folder:

#!/bin/bash

folder=/mnt

var1=$folder/folder-`date +%N`

mkdir $var1
mouviciel
+1  A: 

use the $() syntax whenever possible

#!/bin/bash
folder=/mnt
var1="$folder/folder-$(date +%N)"
mkdir "$var1"
ghostdog74
Now it seemes so obvious, why did i not think of that before.I can only accept one answer so i am using /dev/random
D. Sand