Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to create soft links to mingw's binaries in cygwin.

So far I have: find /cygdrive/c/MinGW/bin/ -name "*.exe" -exec ln -s {} basename {} \;

but I get:

ln: target `/cygdrive/c/MinGW/bin/addr2line.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/ar.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/as.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/c++.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/c++filt.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/cc.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/cpp.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/dlltool.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/dllwrap.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/elfedit.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/envsubst.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/g++.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/gcc.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/gcov.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/gdb.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/gdbserver.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/gettext.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/gprof.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/iconv.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/ld.bfd.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/ld.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/mingw-get.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/mingw32-c++.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/mingw32-cc.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/mingw32-g++-4.6.2.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/mingw32-g++.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/mingw32-gcc-4.6.2.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/mingw32-gcc.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/mingw32-make.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msgattrib.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msgcat.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msgcmp.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msgcomm.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msgconv.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msgen.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msgexec.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msgfilter.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msgfmt.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msggrep.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msginit.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msgmerge.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msgunfmt.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/msguniq.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/ngettext.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/nm.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/objcopy.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/objdump.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/pkginfo.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/quserex-test.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/ranlib.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/readelf.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/recode-sr-latin.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/size.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/strings.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/strip.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/windmc.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/windres.exe' is not a directory
ln: target `/cygdrive/c/MinGW/bin/xgettext.exe' is not a directory
share|improve this question
add comment

3 Answers

To make your command work I don't think you can avoid sub-shelling, something like:

find /cygdrive/c/MinGW/bin/ -name "*.exe" -print0 | xargs -0 -n1 bash -c 'ln -s {} $(basename {})'

If all the files are in the same directory, you can also use cp -s:

cp -s /cygdrive/c/MinGW/bin/* .
share|improve this answer
add comment

Since ln accepts directories as targets:

ln -s /cygdrive/c/MinGW/bin/*.exe /path/to/otherdirectory/
share|improve this answer
add comment
for i in /source/directory/*.exe; do
    ln -s $i /destination/directory/`basename $i`
done
share|improve this answer
    
thats cool, but for the sake of completeness, is there a way to correct what i had above? –  chacham15 Jul 16 '12 at 22:52
    
If there is, I don't know it. I avoid find whenever possible. :) –  Michael Hampton Jul 16 '12 at 22:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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