I want to make an install script for my home PC and I want to make it more flexible.
How to replace my username with current user variable?
Example: download to: /home/THISUSER/Downloads/
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
If you want to do this you should use ...
more ~/.config/user-dirs.dirs # This file is written by xdg-user-dirs-update # If you want to change or add directories, just edit the line you're # interested in. All local changes will be retained on the next run # Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped # homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an # absolute path. No other format is supported. # XDG_DESKTOP_DIR="/discworld/Desktop" XDG_DOWNLOAD_DIR="/discworld/Downloads" XDG_TEMPLATES_DIR="/discworld/Templates" XDG_PUBLICSHARE_DIR="/discworld/Public" XDG_DOCUMENTS_DIR="/discworld/Documents" XDG_MUSIC_DIR="/discworld/Music" XDG_PICTURES_DIR="/discworld/Pictures" XDG_VIDEOS_DIR="/discworld/Videos"
so that would be
echo $(xdg-user-dir DOWNLOAD)
and it will show the default download location (in my case
/discworld/Downloads). Works for all of these words. Like ...
echo $(xdg-user-dir DESKTOP)