0

Is there a command in MSYS2 terminal that can be used to determine whether a file is a symbolic link or a windows shortcut .lnk file? For example:

$ touch a.txt
# Create a symbolic link:
$ MSYS=winsymlinks:nativestrict ln -s a.txt b.txt
# Create a .lnk shortcut file:
$ MSYS=winsymlinks ln -s a.txt c.txt
$ ls -l
total 4.0K
-rw-r--r-- 1 hakon hakon 0 Jan 22 20:54 a.txt
lrwxrwxrwx 1 hakon hakon 5 Jan 22 20:54 b.txt -> a.txt
lrwxrwxrwx 1 hakon hakon 5 Jan 22 20:55 c.txt -> a.txt 

From the above output, it is not possible to distinguish between the two types of links.

Note: I found that I can use fsutil to check for symbolic links, but then I must know in advance that the file is a symbolic link.

10
  • I don't know what relationship there is there between .lnk files and bash done in Ming in windows, but a .lnk file would a)have a .lnk extension and b)if you cat it then you'd see .lnk related junk $cat blah.lnk <-- outputs junk from the lnk file.
    – barlop
    Jan 22, 2021 at 20:06
  • @barlop I want to check from the terminal. There the extension is .txt for both types right? Jan 22, 2021 at 20:08
  • also according to gerrit.googlesource.com/git-repo/+/HEAD/docs/windows.md the nativestrict option thing is to do with whether a file is copied or wheher a symboic link is actually made. Where windows .lnk files come into it I have no idea
    – barlop
    Jan 22, 2021 at 20:08
  • a file would have the same extension whether looking from the terminal or not looking from the terminal (do ensure windows GUI is set to not hide file extensions!)
    – barlop
    Jan 22, 2021 at 20:09
  • @barlop You can see from the output in my question when I type ls -l it shows only .txt files Jan 22, 2021 at 20:10

1 Answer 1

1

You may use the free Nirsoft utility NTFSLinksView:

enter image description here

2
  • Thanks, is there a way I can avoid the gui and use it as command line query tool? Jan 22, 2021 at 21:02
  • It has command-line parameters for creating a text file.
    – harrymc
    Jan 22, 2021 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.