Tag Info

Hot answers tagged

13

See 'CONDITIONAL EXPRESSIONS' in man bash - in this case you want -h: for file in * do if [ -h $file ]; then echo $file fi done


11

You might not really need a script. To show any symbolic links in just the current folder, without recursing into any child folder: find . -maxdepth 1 -type l -print Or, to get some more info, use one of: find . -maxdepth 1 -type l -exec ls -ld {} + find . -maxdepth 1 -type l -print0 | xargs -0 ls -ld To tell if a file is a symbolic link, one can use ...


7

I would say type ln -s $PWD ~/bar/ or ln -s `pwd` ~/bar/ You could use also ln -s $PWD ~/bar/ but I guess you knew that and that is not what you are looking after. So please could you update your question to explain what's your goal? If the path contains spaces, then it would be advisable to use: ln -s "$PWD" ~/bar/


5

Well, a little bit more newbie-friendly answer... Some basics beforehand A simple view on how files are stored on UNIX/Linux systems is: There's a directory entry consisting of the name you see with ls -l and an Inode number (you may see with ls -i). The Inode contains the actual information where your data is stored on the filesystem (among other things ...


4

If you are not in the same directory as the target you must make sure you use the absolute path. ln -s foo/bar baz/quux # fails ln -s ~/foo/bar baz/quux # succeeds


4

via shell-builtins (and globoperator) from l in /from/*.so; do ln -s "$l"; done via find find /from/ -name "*.so" -exec ln -s '{}' ';' doing it via find is better since it works better for huge amount of files.


4

GNU utilities are primarily documented with info pages. From the GNU ln info page: ‘-L’ ‘--logical’ If -s is not in effect, and the source file is a symbolic link, create the hard link to the file referred to by the symbolic link, rather than the symbolic link itself. So this simply dereferences symbolic links given as source arguments.


3

A soft link is enough for your purpose. You simply need to omit the trailing slash, i.e. ln -s ~/me


3

It’s quite simple: You create a symbolic link in ~ that points to ./abc in that directory. The pathname of a symbolic link must be valid in the context of the directory it is in¹. If you indeed want to point to the file that is in your now current directory, you must use the full path. The link must be valid if you want to use it. It can point into ...


3

Try find / -samefile /file/to/compare. There were a similar question: Finding all symbolic and hard links to a file on UNIX


3

A pipe takes the stdout from one process and connects it to the stdin of the next process; that doesn't make any sense for what you're trying to do (ln doesn't do anything with stdin). You probably want something like this (untested): find `pwd` -name "*.php" -execdir ln -s {} /home/frankv/www/bietroboter.de/symlinks \;


3

It does not actually fail. It creates your link inside the given directory: % mkdir dir_1 dir_2 % ln -s dir_1 symlink_dir % ln -s dir_2 symlink_dir % ls -l total 0 drwxr-xr-x 2 user group 60 Oct 16 12:47 dir_1 drwxr-xr-x 2 user group 40 Oct 16 12:47 dir_2 lrwxrwxrwx 1 user group 5 Oct 16 12:47 symlink_dir -> dir_1 % ls -l dir_1 total 0 lrwxrwxrwx 1 user ...


3

The proper way to do this is to use the --no-dereference option like so. $ ln -snf foo2 bar This causes ln to treat the existing symlink as a file. Otherwise, it dereferences bar to foo1, descends into foo1 and uses the original TARGET name as the LINK_NAME and that's why you end up with a symlink to foo2 being created inside the foo1 directory. The ...


2

Your question is kinda confusing. You asked "Is there any way that I can make a symlink to it from ~/dir1 [...] ?" I suppose you meant "from ~/dir2", based on the rest of your post? Your first command $ ln -s ./dir1/file.txt ./dir2/file.txt does not do what you think it does. Assuming you're still in your home directory, the above command creates a ...


2

You can mount remote machine's filesystem using sshfs, and then just make link using ln.


2

See the “Target Directory” chapter in the GNU Coreutils manual: -T --no-target-directory Do not treat the last operand specially when it is a directory or a symbolic link to a directory. This can help avoid race conditions in programs that operate in a shared area. For example, when the command mv /tmp/source /tmp/dest succeeds, there is no ...


2

Try this way: find /download/ -name *.mkv -exec ln {} /movies/ \;


2

You should be able to edit the Makefile and accomplish this quickly. NOTE - This assumes that the Makefile was made by GNU Autotools. According to the Cfengine tarball, they do. First, open the Makefile and look for the flag LDFLAGS. It should look something like this: LDFLAGS=-lfoo -lbar Append to that listing -ldl. This adds a reference to the ...


2

The problem was with my apache config. Here is what allowed it to work, just the FollowSymLinks rule. <Directory "/Users/Joe/Sites/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>


2

If you don't need to do a rename, then the following will symlink every file in a folder to a new folder: ln -s /ZFSRaidz/Multimedia/Anime/Naruto_Shippuuden/* /ZFSRaidz/XBMC/Multimedia/Anime/Naruto_Shippuuden-2/ This will create a symlink in the Naruto_Shippuuden-2 for each file in Naruto_Shippuuden


2

Absolutely: ln -s "$(readlink -f .)" ~/bar (might be good for generality in scripts) or just ln -s ~/foo ~/bar Relatively: ln -s ../foo ~/bar Tab completion will help you type. From grawity's comment and http://lists.gnu.org/archive/html/coreutils-announce/2012-03/msg00000.html: * Noteworthy changes in release 8.16 (2012-03-26) [stable] ...


2

I tend to use ln -s $(pwd)/local_file /path/to/link when I need to link a local file.


1

I hate to say, but I believe you can't do it, at least not in a reliable way. This is about Windows vs. symbolic links vs. Cygwin. Symbolic links as they work in Linux are on filesystem level. The fact that they work with Cygwin is just that it's able to "lie to itself" with help of these special files you mention. Although there is similar facility on ...


1

ln can take either absolute or relative pathnames; the difference matters for symbolic links, but since you asked to make a hard link, it will resolve to the same file either way. Check the ls -li output on ~/abc and ~/download/abc -- you'll see that the link count is 2 and the inode number is the same for both files.


1

Yes, it is true! To use /bigdata/backup as if it was /data/backup you can use these commands in a terminal. First, as you already have a /data/backup directory, move everything in it to /bigdata/backup: mv /data/backup/* /bigdata/backup Then delete your old directory: rm -r /data/backup Now you can link the directories with: ln -s /bigdata/backup ...


1

This is always unintutive to me. I get in the habit of doing: ln -s $(readlink -f /path/to/file) /path/to/link which should work but at the cost of making it non-relative in the actual on-disk link.


1

Use this command: ls *txt | xargs -I R1 sh -c "cat R1 | xargs -I R2 ln -sf R2 R1" Replace ls *txt with something that will output the list of text files that should be symbolic links. For example, find . -name "*txt" would list all *txt files in or under the current directory.


1

Try this: ls * | while read f; do ln -sf "$(cat $f)" "$f" done as in wingedsubmariner's answer, ls * should be replaced with something that will list exactly the files you wanted. I find the ls * | while read f; do # command executed for each file done construct very useful. As I know, this is the right way to handle all file names, e.g. if a ...


1

Traditionally in unix environments, mounting home folders over nfs has typically been done and does what you describe, but is not the best option today for both performance reasons and portability of laptops. If you're looking to sync just dot files you may find using 'git' over ssh a bit easier and less problematic. It works well to sync changes and will ...


1

You can use the -f parameter: ln -s -f /usr/bin/nodejs /usr/bin/node See ln - Linux Command.



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