I want to make a bash script that symlink files for me instead of doing this manually. In my mind the workflow would be something like this :
Question 1 : What is the path of the file/folder to be the source ? ( user input the source )
Question 2 : What is the path of the destination ? ( user input destination )
And then I would take this input and make it variable $SOURCE
and $DESTINATION
Then I would just run something like :
mkdir -p $DESTINATION
ln -s "$SOURCE" "$DESTINATION"
The script should forget the variables after every run, and also run in loop until user decides to quit it.
Also if a user input a destination that ends with a different filename as is often desired, how I can mkdir the directory but exclude the file name?
Like /root/files/1
and I want to symlink it to /var/files/2
. Being "2" just a different name for file "1". How can I make my script that smart?
Sorry if this is a stupid question, I'm just new to this world and this script is going to be one of the most complex I ever wrote.
mkdir
part, see ifdirname
is what you are looking for:dirname path/to/entry.a.b.c
returnspath/to
.