[Bash] Check symlink

Pagina: 1
Acties:

  • CrankyGamerOG
  • Registratie: Juni 2003
  • Laatst online: 27-01 19:49

CrankyGamerOG

Assumption is the mother.....

Topicstarter
Weet er iemand hoe ik snel en handig kan controleren of een reeks symlinks bestaan, en als ze niet bestaan deze aan te maken ?

KPN - Vodafone Ziggo Partner


  • CyBeR
  • Registratie: September 2001
  • Niet online

CyBeR

💩

code:
1
2
3
4
5
6
[marco@elara tmp]$ ln -s foo /tmp
[marco@elara tmp]$ if [ -h foo ]; then echo 1; fi
1
[marco@elara tmp]$ rm foo; touch foo
[marco@elara tmp]$ if [ -h foo ]; then echo 1; fi
[marco@elara tmp]$

Ik neem aan dat je er wel uit komt nu? :P

[ Voor 4% gewijzigd door CyBeR op 02-04-2009 10:23 ]

All my posts are provided as-is. They come with NO WARRANTY at all.


  • zAo
  • Registratie: Maart 2002
  • Laatst online: 27-01 22:43

zAo

GPLv2 Fanboy

Ik heb de manual van AIX gebruikt, maar ik neem aan dat het op een Linux bak het zelfde is:
-L FileName Returns a True exit value if the specified FileName exists and is a
symbolic link.
Dit komt uit de manual van test. Met dingen als "echo $?" kun je bijv, de exitcode uitlezen.

  • CrankyGamerOG
  • Registratie: Juni 2003
  • Laatst online: 27-01 19:49

CrankyGamerOG

Assumption is the mother.....

Topicstarter
CyBeR schreef op donderdag 02 april 2009 @ 10:23:
code:
1
2
3
4
5
6
[marco@elara tmp]$ ln -s foo /tmp
[marco@elara tmp]$ if [ -h foo ]; then echo 1; fi
1
[marco@elara tmp]$ rm foo; touch foo
[marco@elara tmp]$ if [ -h foo ]; then echo 1; fi
[marco@elara tmp]$

Ik neem aan dat je er wel uit komt nu? :P
jahwol , danke sehr :D

stom eigenlijk , maar ik kwam erg gewoon even niet op ! ..... :)
Het is iig gelukt, i thanks yous velly muts
if [ -h /usr/bin/symlink ]; then echo symlink bestaat al;
else sudo ln -s /usr/bin/binary /usr/bin/symlink;
fi
voor anderen die er ff niet opkomen
i blame the coffee machine... die was kapot vanmorgen . en zonder koffie doet mijn brein niks

[ Voor 34% gewijzigd door CrankyGamerOG op 02-04-2009 12:09 ]

KPN - Vodafone Ziggo Partner