Tag Info

Hot answers tagged

17

autofs can do this for you. You can configure any number of mountpoints with various options, and the corresponding filesystems are mounted whenever the mountpoint is accessed. After a given amount of inactivity the filesystems are unmounted again. There are no doubt various ways of using autofs, but here's one way of doing what you're trying to do, based ...


12

That is a feature of the shell that remembers how you got to where you are. If you have realpath installed you can do: $ realpath /home/dazz/test/1 And lacking that if you have python: $ python -c "import os; print(os.path.realpath('.'))" /home/dazz/test/1 or readlink (from coreutils): $ readlink -f . /home/dazz/test/1 or /bin/pwd (not the shell ...


9

You can do this with systemd, so you don't have to install extra software and just have a small amount of extra configuration. Simply add noauto,x-systemd.automount to the options in fstab. noauto to not mount automatically on boot and x-systemd.automount to let systemd mount it on access. Source: ArchWiki - fstab


6

Other answers have covered /bin/pwd vs the shell's builtin pwd. If you want to follow symlinks in the Windows style you mentioned, use cd -P: it will change the PWD variable accordingly. If you want to use -P by default, you can add this line to your .bashrc or .zshrc: set -P Other shells may vary.


6

Contrast pwd and /bin/pwd. pwd, which is a built-in command in many shells, tells you where your shell thinks you are (and hence treats symlinks "soft links" as if they were real directories. /bin/pwd is an external program that tells you where you really are, if necessary by traversing the filesystem tree up to /. It takes no account of symlinks because ...


4

I can provide you with a perl snippet to do this for you: #!/usr/bin/perl # foreach my $i (@ARGV) { # If it is a symlink then... -l $i and do { # First indirection; ensure that it exists and is not a link my $j = readlink($i); print "$i\n" if -e $j and ! -l $j } } If you save that as /usr/local/bin/if-link and make it ...


4

/proc/<pid>/exe does not follow the normal semantics for symbolic links. Technically this might count as a violation of POSIX, but /proc is a special filesystem after all. /proc/<pid>/exe appears to be a symlink when you stat it. This is a convenient way for the kernel to export the pathname it knows for the process' executable. But when you ...


4

The first problem is that your find command will only find links that used full paths, not relative ones. To illustrate: $ ln -s /home/terdon/foo/NonExistantFile foo $ ln -s NonExistantFile bar $ tree . |-- bar -> NonExistantFile `-- foo -> /home/terdon/foo/NonExistantFile In the example above, I created two broken links. The first used an absolute ...


4

If I undersood the question correctly you need files in myfiles which do not have symlinks in images: #!/bin/bash OIFS="$IFS" IFS=$'\n' files="$(find myfiles/ -type f -name '*.jpg' -or -name '*.cr2')" for f in $files; do list="$(find -L images/ -xtype l -samefile "$f")" if [[ "$list" == "" ]]; then echo "$f does not have symlink." fi ...


3

Here's the solution on non-embedded Linux and Cygwin: cp -as SOURCE COPY


2

I assume that the files under myfiles are not symbolic links, and that none of the file names contain newlines. (My approach can still work if these assumptions are violated but it gets more complicated.) I also assume that you have the common readlink utility and that it supports -f to canonicalize paths, which is the case on Linux (both GNU and BusyBox), ...


1

According to the man page of /proc, under Linux 2.2 and later, the file is a symbolic link containing the actual pathname of the executed command. Apparently, the binary is loaded into memory, and /proc/[pid]/exe points to the content of the binary in memory. On the other hand, under Linux 2.0 and earlier, /proc/[pid]/exe is apparently a pointer to the file ...


1

You can try a couple of find commands like this: mkdir FULL-PATH-TO-COPY cd SOURCE find . \( ! -regex '\.' \) -type d -exec mkdir FULL-PATH-TO-COPY/{} \; find * -type f -exec ln -s `pwd`/{} FULL-PATH-TO-COPY/{} \;


1

As pointed out by St├ęphane Chazelas, file modes cover two different notions, file types and file permissions. A file's mode is represented by the value of st_mode in the result of stat(2) calls, and ls -l presents them all together; see Understanding UNIX permissions and their attributes for details. Once a file is created its type can't be changed. In ...


1

I think your confusing mount points and filesystem semantics. The answer is yes though. Symbolism has nothing to do with file systems or mount points. See http://en.m.wikipedia.org/wiki/Symbolic_link


1

Sure can, unless target/source filesystem do support soft links.



Only top voted, non community-wiki answers of a minimum length are eligible