# bash script problem

**URL:** <https://community.unix.com/t/bash-script-problem/148130>\
**Category:** Shell Programming and Scripting\
**Created:** [February 15, 2004, 12:47pm UTC](https://community.unix.com/t/bash-script-problem/148130 "2004-02-15T12:47:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fnoyan](https://community.unix.com/letter_avatar/fnoyan/32/5_5575768a8748004e209b776fc1b2916d.png) [@fnoyan](https://community.unix.com/u/fnoyan)\
**Post date:** [February 15, 2004, 12:47pm UTC](https://community.unix.com/t/bash-script-problem/148130/1 "2004-02-15T12:47:27Z")

</div>

hi  
I am writing a bash script that uses dialog to get user input an diplay messages to user. I have a small problem

dialog --inputbox "blabla" 20 50 2\> /tmp/output  
VAR="'cat /tmp/output'"  
mkdir $VAR

the code below requests user for a directory path to be created.  
But, if the user uses something like this  
~/anydir  
mkdir fails! "~ no such file or directory". In other words, if user uses ~/ instead of /home/username mkdir fails.  
Can anyone help me?

Thanks...

---

<div class="post-metadata">

**Author:** ![kduffin](https://community.unix.com/user_avatar/community.unix.com/kduffin/32/105_2.png) [@kduffin](https://community.unix.com/u/kduffin)\
**Post date:** [February 15, 2004, 9:51pm UTC](https://community.unix.com/t/bash-script-problem/148130/2 "2004-02-15T21:51:42Z")

</div>

Tilde expansion seems to have some oddities surrounding it. Not a satisfying answer, because it doesn't solve the real problem, but this seems to work:

```nohighlight
#!/usr/bin/bash

if [$(grep -c "^\~\/" /tmp/output) -eq 1]
then
   VAR=$(cat /tmp/output | sed -e's/\~//g')
   VAR=$(echo $HOME$VAR)
else
   VAR=$(cat /tmp/output)
fi

mkdir $VAR

```

Cheers,

Keith
