Remove all links


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Remove all links
# 1  
Old 10-27-2008
Remove all links

How can I remove all links (and just the links) from a file hierarchie (recursively)? With unlink I don't see any possibility to do that.

Thanks!
# 2  
Old 10-27-2008
use find e.g.:

Code:
#  find . -type l -exec ls -l {} \;

to get the ls...replace the ls -l with rm to remove....

# 3  
Old 10-27-2008
If you have zsh:

Code:
rm -- **/*(D@)

# 4  
Old 10-27-2008
I like that one:
Code:
find . -type l -exec rm {} \;

By the way, what is {} \; for?
# 5  
Old 10-28-2008
find loops through all directories and subdirectories starting at '.' and uses {} to inform a third-party program which file is currently being analyzed. So when rm is called the value of {} is already updated to be the current directory being removed.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. AIX

List all the soft links and hard links

Hi I'm logged in as root in an aix box Which command will list all the soft links and hard links present in the server ? (2 Replies)
Discussion started by: newtoaixos
2 Replies

2. Solaris

Hard Links and Soft or Sym links

When loooking at files in a directory using ls, how can I tell if I have a hard link or soft link? (11 Replies)
Discussion started by: Harleyrci
11 Replies

3. Solaris

Unable to remove links of Cleared metas

Hi, have few meta devices which were cleared some year ago but still appear in /dev/md/rdsk. If I create a same meta device again, it shows old timestamp of 2009yr I tried devfsadm -C to clear unlinked links but of no use. What am I missing ? (2 Replies)
Discussion started by: tuxian
2 Replies

4. UNIX for Advanced & Expert Users

About links

why directory has two links as default. what's the purpose? (1 Reply)
Discussion started by: nagalenoj
1 Replies

5. UNIX for Dummies Questions & Answers

links

how can we know the different links (hard and soft) to a file ..... i got a file in my directory and i need to know the different links attached to this file any one plz help thanks.. (1 Reply)
Discussion started by: uniqmaniak
1 Replies
Login or Register to Ask a Question