fojalar
fojalar

Reputation: 47

Using bash to find absolute path to specific directory

I've been trying to write a simple bash script to enter into a couple of directories and install all RPMs in those directories. However, I am having difficulty getting the absolute path for the directories. Right now I am trying:

#!/bin/bash
cd readlink -f my_dir;
mvn clean install;
sudo rpm -U $(find . -type f -name \*.rpm);

The code for the other directories is exactly the same save for the directory name. The issue I am having is cd readlink -f my_dir; attempts to change the directory to absolute/path/to/cur_dir/my_dir; it tacks on the name of the directory at the end. How do I solve this issue?

Clarification

I am trying to get the absolute path to a directory regardless of my current position in the file system. What I am getting now is the absolute path to my current directory with the name of the desired directory appended to it.

Upvotes: 1

Views: 102

Answers (1)

John Zwinck
John Zwinck

Reputation: 249642

cd readlink -f my_dir should be cd $(readlink -f my_dir).

Upvotes: 3

Related Questions