Sample Header Ad - 728x90

Can I reprogram the pwd command to add a trailing slash?

0 votes
1 answer
212 views
WHen I use the pwd command, it prints e.g /opt instead of /opt/. I would like it to print the trailing slash. However, I tried adding the following line to my ~/.bash_aliases file:
alias pwd=" echo "${PWD}/" "
But it doesn't work properly. Instead of printing my present working directory with a trailing slash, it prints the working directory I was in **at the start of the terminal session**, or at the last time I ran the source ~/.bashrc command. Even when I name the command something different, like cwd, it still behaves this way. So - my question is, can I have some way to have an alias that prints my present working directory, followed by a trailing slash? Thanks.
Asked by K.defaoite (153 rep)
Jan 18, 2024, 05:37 PM
Last activity: Jan 18, 2024, 07:23 PM