How to rename a file in a directory using the current directory
I want to rename a file (home / Desktop / ali / a / b.txt)
I wrote a bash file
#!/bin/bash
mv a/b.txt a/c.txt
and put it in ali directory, I go to ali directory in terminal, but when I run bash file it cannot find /b.txt file
I know this mv home/Desktop/ali/a/b.txt home/Desktop/ali/a/c.txt
will work fine, but is there a way to use the current directory to shorten the addressing?
source to share
You don't need to provide a location if you are in that directory.
For example, you have a file A
on your desktop, so you navigate there and do:
mv A B
The file has A
been renamed to B
in this directory
But if you want to do it from somewhere else, you do
mv directory/A directory/newfilename
source to share