开发者

Save path to specific folder in shell script

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.


use the $() syntax whenever possible

#!/bin/bash
folder=/mnt
var1="$folder/folder-$(date +%N)"
mkdir "$var1"


Define var1 before creating the folder:

#!/bin/bash

folder=/mnt

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

mkdir $var1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜