Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

391
Views
Absolutize possibly non-existent path in bash? (linux)

There are many instances on SO where people have asked how best to absolutize a path in bash, but I haven't found any that deal with absolutizing non-yet-existent paths.

The cd $1 && pwd method does not work at all for non-existent paths.

The readlink -f $1 method will only work for one level of non-existence; that is, it will work for "~/sdkjf", but not for "~/sdkjf/qweuio"

Ideally, I would like a method that would expand the latter to /home/username/sdkjf/qweuio ... and would also do similar transforms for ./ and ../

Can you recommend a solution?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

readlink -m $1

From the manpage:

  -m, --canonicalize-missing
          canonicalize  by  following  every  symlink  in every component of the given 
          name recursively, without requirements on components existence
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!