Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

tilde-expansion

Why use $HOME over ~ (tilde) in a shell script?

August 7, 2023 by Tarik

Tilde expansion doesn’t work in some situations, like in the middle of strings like /foo/bar:~/baz

Categories shell Tags environment-variables, home-directory, scripting, shell, tilde-expansion Leave a comment

How do I find a user’s home directory in Perl?

April 14, 2023 by Tarik

~ is a bash-ism rather than a perl-ism, which is why it’s not working. Given that you seem to be on a UNIX-type system, probably the easiest solution is to use the $HOME environment variable, such as: if ( -e $ENV{“HOME”} . “/foo.txt” ) { print “yes ,it exists!” ; } And yes, I know … Read more

Categories perl Tags home-directory, perl, tilde-expansion Leave a comment

How to manually expand a special variable (ex: ~ tilde) in bash

October 23, 2022 by Tarik

If the variable var is input by the user, eval should not be used to expand the tilde using eval var=$var # Do not use this! The reason is: the user could by accident (or by purpose) type for example var=”$(rm -rf $HOME/)” with possible disastrous consequences. A better (and safer) way is to use … Read more

Categories bash Tags bash, scripting, tilde, tilde-expansion Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa