New answers tagged

3

Add the following line to your ~/.inputrc file: set mark-symlinked-directories on See "Readline Init File Syntax" in the Bash Reference Manual for more on this topic.


1

The filesystem on Mac OS X (HFS+) does not support hard links to symbolic links: $ touch file $ ls -l file -rw-r--r-- 1 kk staff 0 Jun 17 18:35 file $ ln -s file slink $ ls -l file slink -rw-r--r-- 1 kk staff 0 Jun 17 18:35 file lrwxr-xr-x 1 kk staff 4 Jun 17 18:36 slink -> file The following would ordinarily create a hard link to a symbolic link, and ...


0

You cannot make hardlinks to symbolic links (this is not a "limitation" of OS X). A hardlink is a reference to an inode, and a symbolic link is not an inode but only an entry in the directory with some additional information. You may be thinking of Windows, which has analogous features, which behave differently. rsync does have a --copy-links option which ...


0

stat doesn't count symlink counts, hardlinks though - if that helps. There's no way to resolve what you're asking.


3

With GNU find, you can do: find -L / -xtype l -prune -samefile foo -exec ls -ld {} + That will find all the files of type symlinks which eventually resolve to the same file as foo. That will also include symlinks to symlinks or hardlinks to foo1. With -L, symlinks are followed. We want that to find files linked to foo, but we don't want to follow ...


2

Two possible solutions that spring to mind. 1. Iterate across all the directories in LOREM and symlink them to $HOME cd "$HOME/LOREM" for item in * do test -d "$item" || continue mv -f "$HOME/$item" "$HOME/$item.DELETE_ME_LATER" 2>/dev/null ln -s "$HOME/LOREM/$item" "$HOME/$item" done # Once you are happy that only the correct files have ...


5

If you're using bash, zsh or any POSIX shell, then cd -P pwd -P or to make it permanent. in bash: set -P or set -o physical in zsh: set -w or set -o chaselinks in other POSIX shells: alias cd='cd -P' in tcsh: set symlinks = chase But the effect you're seeing is created by the shell, not by the link itself. So the answer to your actual question is "no"...


4

There's no link from a file to symlinks that point to it, so there's no direct way of considering example and finding link_example which links to it. So deleting symlinks pointing to a file along with the file involves finding all the symlinks first. You don't specify what system you're using, but if you have GNU find, you can delete a file and its links ...


3

If you don't have write permission in the parent directory, you can't make any changes in the parent directory; this includes deleting the target directory, and creating a symlink. In any case, ln won't overwrite a directory, even with -f.


0

I have an program that appends to a log file. These log files are created monthly each with a different name. Rather than have the software figure out the exact filename, I use a "generic" filename (say data.log) which is a symbolic link that points to the current file for that month. This is automated on a cron job. Now as a new monthly file is created, it ...


2

If you mean that you want to create symbolic links from $HOME/this, $HOME/there/that, $HOME/Data/ddd, etc. but not $HOME/Data or $HOME/somewhere/Labs, then the criteria for matching should be find "$HOME" ! \( -name Data -o -name Labs \) -exec … You were missing parentheses. Juxtaposition binds tighter than -o so -name Data -o name Labs -exec … executes ...


1

In Bash you can do it by enabling the extglob option: $ shopt -s extglob #Enables extglob $ ls -l "$HOME"/!(Data|Labs|Documents) #Test run $ ln -s "$HOME"/!(Data|Labs|Documents) \ "$HOME"/Documents/ #Create symlinks $ shopt -s extglob #Disable extglob ...


6

If you have gnu parallel you could try with parallel ln -s /path/file {} ::: /path/dest1 /path/dest2 /path/dest3 or, to symlink multiple targets to (the same) multiple destinations parallel ln -s {1} {2} ::: /path/file1 /path/file2 ::: /path/dest1 /path/dest2


-1

To make the link for everything find finds other than its first result, you can do this: for item in "$(find "$HOME" ! -name Data -o -name Labs | tail --lines=+2)"; do ln -s "$item" "$HOME"/Documents/ done


11

You can't do this with a single invocation of ln,but you could loop through all necessary destinations: $ for i in "$HOME/Documents/" "$HOME/Desktop/"; do ln -s "$HOME/file" "$i"; done


5

It's no less verbose than two separate ln -s invocations: echo $HOME/Documents/ $HOME/Desktop/ | xargs -n 1 ln -s $HOME/file but that only works for absolute paths (because symbolic links are interpreted relative to their parent directory, unless they're absolute). (The relative cost drops of course as the number of links goes up. Also, this snippet ...


0

Your link points to /folder2.Your pwd is /folder1/linkToFolder2, that is the same than /folder2/, and 'ls ..' in all the cases should show you the above directory, wether if you are in /folder1 or /folder2


1

Dropbox apparently doesn't support symlinks. So deleting a symlink from the Dropbox GUI deletes the link, as well as the items pointed to.



Top 50 recent answers are included