• Uncategorized

About linux : How-do-i-grep-another-file-if-one-file-path-at-the-same-location-is-mentioned

Question Detail

Suppose I have a file at location /var/log/abc.txt and another file at same location /var/log/xyz.txt. But in my program i have mentioned /var/log/abc.txt location.. now using same location how can i use the xyz.txt file without specifying the location of it.
I want my command to cut abc.txt and replace with xyz.txt

Question Answer


dirname /var/log/abc.txt

It return the path /var/log


newfile="$(dirname $oldfile)/xyz.txt"
echo $newfile

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.