Skip to main content

Questions tagged [readlink]

Use this tag for questions related to the readlink command which prints resolved symbolic links or canonical file names.

Filter by
Sorted by
Tagged with
0 votes
1 answer
55 views

How to get bash autocompletion to mimic the behavior for a certain command?

I'm writing a script wrapping a certain Linux command. Now, that command, when I use it directly on the command-line, has some autocomplete behavior. For example, if I type the command name, then ...
einpoklum's user avatar
  • 9,643
0 votes
1 answer
126 views

Linux alternative to "readlink -e" for nonexistent files

On Windows, I often create a full path to a nonexistent file so that I can provide it to file-saving dialogue boxes, thus telling the host application where to save a file. Using Cygwin, this is done ...
user2153235's user avatar
2 votes
2 answers
2k views

How do I resolve a relative path in a POSIX shell if readlink/realpath is not available?

If neither utility readlink, nor realpath is available (I think today mostly from GNU coreutils?), what can I use in POSIX shell scripting to resolve a relative path? There is a realpath C function, ...
finefoot's user avatar
  • 3,132
0 votes
0 answers
55 views

What is the hex string in readlink output

When I run this command 'readlink /proc/3192/exe', it returns the output '/usr/libexec/qemu-kvm;62d69987 (deleted)'. There is a hex string ';62d69987' in the output, what is it?
Tianxin's user avatar
0 votes
1 answer
994 views

'is a directory' error when trying to use readlink

I am messing around in bash to try and create a custom PS1 but I'm running into an error when I try to print the absolute path of the directory I am in. I have a directory $FIRMWARE which is a symlink....
potapeno's user avatar
  • 103
1 vote
0 answers
851 views

Can realpath command completely replaced by readlink command?

Given that realpath command does not exists on every unix platform, I would like to replace realpath with readlink command in order to make my shell script as cross-platform as possible. The thing is ...
Panagiotis Simakis's user avatar
5 votes
2 answers
784 views

readlink -f and -e option description not clear

-f, --canonicalize canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist -e, --canonicalize-existing canonicalize by following ...
jlas's user avatar
  • 95
1 vote
2 answers
423 views

combine ls -alt with readlink

I have a directory containing a lot of symbolic links and some huge subdirectories. I want to get a detailed listing, sorted by time, of just the files in the parent directory, but with targets ...
Leo Simon's user avatar
  • 453
2 votes
1 answer
1k views

How do I restore files removed from /usr/bin?

TL;DR at the bottom. Background: The following occured on my CentOS 6.10 production server. I was using a browser based terminal program to run the program Midnight Commander which is a console-...
iskyfire's user avatar
  • 133
-1 votes
2 answers
2k views

Why says readlink that there is no such file or directory [duplicate]

I am creating a bash function that should return true/false if a specified symlink refers to specified target. I based myself on https://unix.stackexchange.com/a/192341/40237 However, I am having ...
Rabarberski's user avatar
1 vote
1 answer
3k views

copying a symlink to a target file using cp -t

I have a symlink to a file on my Ubuntu system, and I need to copy the original file to a different directory and have a new name there. I am able to copy it to a different directory using readlink -...
Akash Sundaresh's user avatar
1 vote
3 answers
3k views

Option to readlink on Linux and MacOS that will return filepath if it's not a symlink

I have this: file_path="/actual/file/path" read_link="$(readlink "$file_path")" # just in case it's a symlink readlink will echo an empty string if it's not a symlink? Is there an option to ...
Alexander Mills's user avatar
4 votes
2 answers
246 views

How do I test for link to a link?

I want to test whether a file is a link to another link. I tried readlink but it doesn't work the way I need it: [email protected],1:~/subdir1 $ ll lrwxrwxrwx 1 pi pi 13 Apr 10 14:34 hellolink ->...
Arjen's user avatar
  • 188
2 votes
2 answers
472 views

How to tell without knowing the mount point that a device UUID is mounted?

System: Linux Mint 19.1 Cinnamon 64-bit, based on Ubuntu 18.04 LTS. I would like to know if it is possible to get the following information: Is this UUID (of a block device) mounted or not? (without ...
Vlastimil Burián's user avatar
3 votes
1 answer
1k views

Overwrite symlink with original file

I have a directory with some symlink file, for example: /home/user/symlink/$(*symlink_file_name1*).mkv /home/user/symlink/$(*symlink_file_name2*).mkv And I have another directory with the original ...
Julien Blanchon's user avatar
0 votes
3 answers
2k views

readlink -f doesn't work as expected

This is a script I'm writing for exercise. It should recursively find all regular files in the current directory's subtree and change the last modification date to yesterday date. #!/bin/bash ...
ikeDiM's user avatar
  • 137
1 vote
2 answers
1k views

Apply readlink to a non-symlink file?

This code from Stack Overflow is to get the pathname to the parent directory of a script inside the script, even if the script is run via a symlink to it: if [ -L $0 ] ; then DIR=$(dirname $(...
Tim's user avatar
  • 103k
0 votes
1 answer
71 views

How can I set ENV from a path

I just installed android-sdk using Homebrew. The path is /usr/local/Caskroom/android-sdk/3859397,26.0.1. I know I can export ANDROID_HOME with that value. How can I set it dynamically using the ...
Jin Kwon's user avatar
  • 510
7 votes
1 answer
303 views

Looking for tested utility to get the absolute path to a relative symlink target

NB: In the original title of this post, I used the word standard in the everyday sense of "well-established" (and therefore time-tested, as a contrast to quick solutions I could roll myself). In the ...
kjo's user avatar
  • 15.6k
3 votes
2 answers
1k views

Trace route of a symbolic link

I want to resolve a symbolic link with the additional option to print the whole linkage. For example I want to run a command like readlink -f "symlink2" which reports each entry of the linkage. In ...
Hölderlin's user avatar
  • 1,196
3 votes
3 answers
2k views

Real current directory [duplicate]

Obviously I know about pwd and readlink, but is there a command to find out the real absolute path to the current directory (ie, resolving links and dots)?
Jonathan H's user avatar
  • 2,393
1 vote
2 answers
133 views

Get full directory of $file

My first shell script #!/bin/bash echo "Input your file" read $file path=(readlink -f $file) echo "$USER, $path" >> scriptlog.txt it said missing operand. How can I fix it?
H.Dinh's user avatar
  • 25
1 vote
2 answers
304 views

How do I keep command options from breaking other scripts executed within my command?

I have a bash shell script(my_script.sh) which runs a script(their_script) during execution. My script (my_script.sh) looks like this : THISDIR=`dirname $(readlink -f $0)` main() { cd $THISDIR ...
karobar's user avatar
  • 115
1 vote
1 answer
3k views

sym link for android-studio/bin/studio.sh

I tried creating a symbolic link for android studio as such sudo ln -s android-studio/bin/studio.sh /usr/bin/asw I chose asw as the keyword to hopefully launch the executable studio.sh from anywhere ...
phillipsk's user avatar
  • 161
8 votes
2 answers
19k views

explain the options of readlink command

Can someone please explain me following options of readlink command in simple language: -f, --canonicalize canonicalize by following every symlink in every component of the given ...
Alex Jones's user avatar
  • 6,383
122 votes
3 answers
53k views

What's the difference between "realpath" and "readlink -f"

I've read a lot about the realpath command and how it has been deprecated with readlink -f being now recommended.  I have also seen in some places that the reason why realpath was introduced was for ...
Felipe Leão's user avatar
  • 1,385