Tag Info

Hot answers tagged

4

The -i/--in-place flag edits a file in place. By default, sed does the (arguably) simplest possible thing and doesn't check if the file is a symlink, before reading from it, transforming, then truncating and writing. GNU sed has a --follow-symlinks flag, which makes it behave as you want with symlinks: $ echo "cat" > pet $ ln --symbolic pet pet_link $ ...


3

When links are put in /usr/bin or /usr/local/bin, this is often because the actual binary is living somewhere else. Why is it living somewhere else? Usually because it is a part of a group of files, often in its own subdirectory, which it depends on to run. Why can't all those files be dumped into /usr/bin or /usr/local/bin? Because those locations are only ...


2

Shells keep track of symbolic links as a convenience for users. This has the nice effect that cd foo && cd .. always goes back to the original directory, even when foo is a symbolic link to a directory. It has two kinds of downsides: the main one is that other programs don't behave this way; additionally, symbolic directory tracking introduces ...


2

It is because cp isn't playing the same link game your shell is. Your shell is tracking the links to the current working directory as an indirection to the current working directory, but the kernel doesn't want any of that nonsense when the shell goes to call up cp - rather the kernel will make the cp's current working directory a fully qualified absolute ...


2

You can ask cp to create a so-called link tree for you: cp -al foo foo_0311 -a copies everything recursively, and -l creates hard links for files instead of copying them. If foo_0311 already exists then you should use cp -al foo/* foo_0311 instead. This creates hard links rather than symbolic links, so they don't appear with -> in the output of ls ...


2

Assuming that FollowSymLinks is set correctly set, I suppose that the problem is that your home directory does not allow anyone else to traverse into it (Do the parent directory's permissions matter when accessing a subdirectory?). That's the default on Fedora; it looks like the default on Ubuntu is more permissive, which is why switching to that worked. ...


2

Verify symlinks are enabled inside apache itself. Apache doesn't necessarily allow for symlink redirection, even when permissions are fine. <Directory /var/www/myapp> Options +FollowSymLinks AllowOverride All ... </Directory>


2

With GNU find (the implementation on non-embedded Linux and Cygwin): find /search/location -type l -xtype d With find implementations that lack the -xtype primary, you can use two invocations of find, one to filter symbolic links and one to filter the ones that point to directories: find /search/location -type l -exec sh -c 'find "$@" -L -type d -print' ...


2

It is possible to copy relative symlinks using --links option: -l, --links When symlinks are encountered, recreate the symlink on the destination. Also: Note that --archive implies --links. Example: $ mkdir /tmp/tarsnap-test/ $ cd /tmp/tarsnap-test/ $ mkdir orig backup $ cd orig/ $ mkdir dir $ ln -s dir symlink $ ll total ...


1

I found solution: #!/bin/bash mkfifo /etc/z.conf ( while (true) do ssh x@y cat /etc/z.conf > /etc/z.conf done ) &


1

If you want to check whether $path is a symbolic link whose target is /some/where, you can use the readlink utility. It isn't POSIX, but it's available on many systems (GNU/Linux, BusyBox, *BSD, …). if [ "$(readlink -- "$path")" = /some/where ]; then … Note that this is an exact text comparison. If the target of the link is /some//where, or if it's ...


1

I heard that symlinks can't be edited. So do I have to create new symlinks and then overwrite the existing ones? Symlinks can't be edited, that is correct. You can replace symlinks to files in a single operation with the -f option to ln, and if you add -T you can process symlinks to directories in the same way: ln -sfT /data/Tim/dir1 symlink1 will ...


1

Try: find /search/location -type l -exec test -e {} \; -print From man test: -e FILE FILE exists You might also benefit from this U&L answer to How can I find broken symlinks; be sure to read the comments too. Edit: test -d to check if "FILE exists and is a directory" find /search/location -type l -exec test -d {} \; -print


1

Try parent_path=$(echo "$current_path"/ | sed -e "s|[^/]||g" -e "s|/|../|g") cd "${current_path}" ; ln -s "${parent_path}${parent_file_to_link}" This works simply by counting the slashes in "${current_path}".  The desired depth is one more than the number of slashes (e.g., the depth of test/dir/hello, which contains two slashes, is 3), so we simply add a ...


1

No, not really. You can test the by debug tracing your operation. Assuming you're on linux, that's strace. mkdir test1 ln -s test1 test2 strace -o strace1.log ls -l test1 strace -o strace2.log ls -l test2 Then diff your two logs. You'll see they're basically the same sequence of operations. They call lstat which is a version of stat that follows ...


1

If I understand your question correctly you need to use realpath with -s: -s, --strip Only strip . and .., components, but do not resolve symbolic links. $ realpath -s a/b/c /tmp/a/b/c $ readlink a/b/c s



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