So I've been starting bash scripting, and I'm making a script that will autoinstall from source (so essentially it just compiles tarballs for you). I need it to change directories in order to go to a tarball. However, whenever I use this command
read path
cd $path
I always get the error tar-installer.sh: line 13: cd: ~: No such file or directory
For anyone needing it, here's the full script...
#!/bin/bash
# This program auto-installs tarballs for you.
# I designed this for Linux noobies who don't
# know how to install tarballs. Or, it's for
# people like me who are just lazy, and don't
# want to put in the commands ourselves.
echo "Tar Installer v1.1"
echo "Gnu GPL v2.1"
echo -n "Path to tarball:"
read path
cd $path
echo -n "Please enter the file you wish to complile..."
read file
if $file =="*.tar.gz"
then
tar -xzf $file
else
$file =="*.tgz"
then
tar -xzf $file
else
$file =="*.tar.bz2"
then
tar -xjf $file
The final part with the tarballs is still a work in progress. But the directory I used for cd path
was ~/Downloads/
It's probably an easy fix, but I don't know how to fix it.