1

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.

0

1 Answer 1

3

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

2
  • I tried that, but it is still getting the absolute path to my current directory instead of my_dir
    – fojalar
    Commented Jun 28, 2017 at 17:18
  • What do you get if you run readlink -f my_dir in your terminal? Commented Jun 29, 2017 at 1:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.