Tag Info

New answers tagged

1

With a GNU ls at least (and, apparently, tcsh's implementation) you can hack the $LS_COLORS environment variable to insert delimiters where you like (but tcsh's builtin ls-F doesn't do link targets - only link flags) Usually ls inserts arbitrary non-printable terminal escapes based on the values stored within that environment var, but there's nothing ...


3

ls unfortunately doesn't have an option to retrieve file attributes and display them in an arbitrary way. Some systems have separate commands for that (for instance GNU has a stat command or the functionality in GNU find). On most modern systems, with most files, this should work though: $ ln -s '/foo/bar -> baz' the-file $ LC_ALL=C ls -ldn the-file | ...


4

Use the file command. [sreeraj@server ~]$ ls -l mytest lrwxrwxrwx 1 sreeraj sreeraj 15 Dec 12 09:31 mytest -> /usr/sbin/httpd [sreeraj@server ~]$ file mytest mytest: symbolic link to `/usr/sbin/httpd' or [sreeraj@server ~]$ file -b mytest symbolic link to `/usr/sbin/httpd' [sreeraj@server ~]$ Also, please go read through man page of ls and check ...


0

You should not move any directory pertaining to a Solaris package to a different directory then use a symbolic link to fix the path. While it will work initially, as soon as you install either a patch or a new package that share some part of the previous pakage path, the symbolic link will be removed and replaced by a plain directory by the Solaris package ...


1

pax can be really useful in these cases. In fact it would be easier if I could discover a pax that does the -o listopt=... option specified by POSIX but, despite my looking, I've yet to find one that does. I use the one mirabilos maintains - the BSD pax (mirabipax?) - which is probably the one most others do as far as I know. Anyway you get to regex ...


2

I assume you are using bash, so I would use globstar to loop through all directories at once with **. After that all what is left is to play a little bit with readlink, realpath, etc: shopt -s globstar for file in c1/** d1/**; do if [[ -h "$file" ]]; then if [[ "$(readlink -f "$file")" == "$(realpath a/b/original-target)" ]]; then ln ...


0

I created a script that will do this. The script converts all hard-links it finds in a source directory (first argument) that are the same as in the working directory (optional second argument) into symbolic links: https://gist.github.com/rubo77/7a9a83695a28412abbcd It has an option -n for a dry-run, that doesn't do anything but shows what would be done. ...


0

This is not impossible, but as @tkausl has suggested it involves searching the whole partition, unless you have some other knowledge of possible locations. If there are more than 2 links to the file there is no way to identify the "original" file. I have written programs to find all hardlinks which have the same target. This is certainly NOT a task to be ...


4

You have mistaken the output of at least one command. The permissions of a symbolic link are always rwxrwxrwx, or rather they don't have permissions at all: $ touch file $ ls -l total 0 -rw-rw-r-- 1 muru muru 0 Dec 5 20:53 file $ ln -s file link $ ls -l total 0 -rw-rw-r-- 1 muru muru 0 Dec 5 20:53 file lrwxrwxrwx 1 muru muru 4 Dec 5 20:53 link -> ...


0

There are no limits for symlinks (just for hardlinks). As a consequence a symlink may not work ("dangling symlink").


0

I guess you should separate the file handling from the directory handling. Make the directories first. In the GNU world: cd /dir2 find /dir -mindepth 1 -maxdepth 1 -type d -exec mkdir {} \; And then the symlinks: find /dir -mindepth 1 -maxdepth 1 -type f -exec ln -s -t /dir2 {} +


0

A symbolic link doesn't affect the permissions of its target, it's just a way to store a path that's followed automatically by the kernel. In fact, many systems ignore the permissions of symbolic links altogether. A hard link wouldn't help you since that's a way to have the same file (same content, same metadata including permissions) at several locations ...


2

A symlink won't work. A hard link (when possible) won't work either because both files will have the same permissions. But I'd do the following: instead of a link, write a shell script /usr/bin/myscript.py that executes the script itself: #!/bin/sh exec python /path/to/wherever/I/have/put/myscript.py "$@" The "$@" passes any parameters through; if your ...


2

-rw--r--r-- 2 kamix users 5 Nov 17:10 hardfile.txt ^ That's the number of hard links the file has. A "hard link" is actually between two directory entries; they're really the same file. You can tell by looking at the output from stat: stat hardlink.file | grep inode Device: 805h/2053d Inode: 1835019 Links: 2 Notice again the ...


2

A hard linked file has more than one link (the 2 after the permission flags). You can use the stat command to easily extract this information: $ stat --printf '%h\n' hardfile.txt 2 See the manpage for stat (man 1 stat) for information about other values and how to print them.


1

The $PATH environment variable is only used when you run an executable. In your case, you've symlinked a directory. As a directory isn't an executable, then your shell will not search $PATH for it. If you symlink to an executable, you'll find that it works as expected.


1

None of the following are the real reason for disallowing hard links to directories; each problem is fairly easy to solve: cycles in the tree structure cause difficult traversal multiple parents, so which is the "real" one ? filesystem garbage collection The real reason (as hinted by @Thorbjørn Ravn Andersen) comes when you delete a directory which has ...



Top 50 recent answers are included