Tag Info

New answers tagged

0

This will print out the names of broken symlinks in the current directory. for l in $(find . -type l); do cd $(dirname $l); if [ ! -e "$(readlink $(basename $l))" ]; then echo $l; fi; cd - > /dev/null; done Works in Bash. Don't know about other shells.


4

The symlinks appearing in red indicates "broken" links - i.e. the target does not exist. This seems to indicate that whatever was providing /c is not mounted. You need to figure out the device that provides that data and mount it.


3

Use relative symlinks instead: media └disk1 ├folder1 │ └folder2 (symlink to ../folder2) └folder2 When copied it will be the same, and since that is relative to the location, it will serve the same purpose in disk2. In case that's not clear, the idea is: cd /media/disk1/folder1 rm folder2 ln -s ../folder2 folder2 This last command is different ...


2

Go to the directory where you want to create the link and run the following command: ln -s ./ 2015 The ln command creates links, see man ln: -s, --symbolic make symbolic links instead of hard links


2

This is a symbolic link. Go the directory where they are pointing to and execute: ln -s . 2015 should do it. Note the destination shall not exist. If there is currently a directory named 2015 move it before linking.


1

Let's have a look at what your first command did: it created a symbolic link math in your current directory that points to the absolute path of the current directory. Lets inspect a bit closer: user@host:/free$ ls -al /free total 4 drwxrwxrwt 2 root root 40 Oct 14 10:29 . drwxr-xr-x 24 root root 4096 Oct 1 22:28 .. user@host:/free$ ln -vs /free math ...


3

A program that acts on the contents of a file always acts on the target, not on the symbolic link, because symbolic links have no contents of their own. A program that acts on the metadata of a file (timestamps, owner, permissions, …) usually acts on the target, but some programs have options to act on the symbolic link instead (for example, chown -h, touch ...


0

After looking around and playing with the find command I found it was easier to just loop over things using ./*/. Thanks for all the help! I made a script on my github account that is much more finely tuned. Although it is gitlab specific It would only take a few minutes to modify it for whatever you need ...


1

find can be used to execute a command in the context of every directory under a specific path. The following command looks for all files under /var/opt/gitlab/git-data/repositories/web/ that are directories (-type d) and creates a symbolic link relative to the current directory it is examining (represented by {} in -exec ) So the following find command ...


4

You'll probably want to use the find command using the maxdepth option. I created this sample directory structure: /tmp/parent /tmp/parent/subdir2 /tmp/parent/subdir1 /tmp/parent/subdir4 /tmp/parent/subdir4/notme /tmp/parent/subdir3 Let's say I wanted to create a symlink to /tmp/hooks in each subdir but not the notme subdir: root@xxxxxxvlp12 ~ $ find ...


2

ln works a bit like cp. If there are more than two arguments, the last one is treated as a directory. From man ln: ln [option]... target... directory You'll need to use a for loop instead.


2

dpkg -S can't tell you which package installed the symlink because it only looks at the files that were unpacked from the packages. This information is provided by the *.list files in /var/lib/dpkg/info/*.list. Every file on a Debian system can only be owned by one package. If you try to install a package that contains a file that is already provided by ...


2

You can use readlink to print where a link points to. The argument to readlink without options has to be a link, if you pass it a file, it will not print anything. The -f option for readlink, from the coreutils package, recursively follows links and prints the filename even if the argument already is a file. If you do (-n supresses the newline at the end of ...


1

Lets create simple script: #!/bin/bash mypath=$1 while [[ "${#mypath}" -gt 1 ]]; do file "$mypath" mypath="$(dirname $mypath)" done Test: $ ./linksinfo /usr/src/linux/kernel/../../../../bin/sh /usr/src/linux/kernel/../../../../bin/sh: symbolic link to `bash' /usr/src/linux/kernel/../../../../bin: directory ...


7

Because bash (and possibly other shells) track the path you descended, including symlinks, in order to make your trail back up look like the one down. Bash knows how you got to the working directory because cd must be a shell built-in. When you run ls .. the shell can't substitute the "symbolic path" because grep .. is also valid and translating .. would be ...


0

Use archive mode to achieve this rsync -a



Top 50 recent answers are included