Help!

softlink

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> System Development RSS
Next:  mkdir -p without calling system()  
Author Message
guru
External


Since: Jul 20, 2007
Posts: 9



PostPosted: Wed Aug 01, 2007 10:48 pm    Post subject: softlink
Archived from groups: comp>os>linux>development>system (more info?)

Hi

I wanted to remove all softlinks in a given directory(ex: linux source
directory).

How this can be done.? can we do it using a shell command or i have to
write piece of code for it.

Regards
Gururaja
Back to top
Paul Pluzhnikov
External


Since: Nov 07, 2004
Posts: 355



PostPosted: Wed Aug 01, 2007 10:51 pm    Post subject: Re: softlink [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

guru <guru.naveen RemoveThis @gmail.com> writes:

> I wanted to remove all softlinks in a given directory(ex: linux source
> directory).

If I were you, I'd change my "screen name" from "guru" to something
less ambitious, before asking such a beginner question Smile

> How this can be done.?

find . -type l -print0 | xargs -0 rm -f

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Back to top
Josef Moellers
External


Since: Jul 07, 2005
Posts: 389



PostPosted: Thu Aug 02, 2007 9:20 am    Post subject: Re: softlink [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Paul Pluzhnikov wrote:
> guru <guru.naveen DeleteThis @gmail.com> writes:
>
>
>>I wanted to remove all softlinks in a given directory(ex: linux source
>>directory).
>
>
> If I were you, I'd change my "screen name" from "guru" to something
> less ambitious, before asking such a beginner question Smile
>
>
>>How this can be done.?
>
>
> find . -type l -print0 | xargs -0 rm -f

TMTOWTDI

for file in *
do [ -L "$file" ] && rm -f "$file"
done

Yours also recursively removes all symbolic links in all subdirectories,
add "-maxdepth 0" to the find command. Mine does so only in the current
directory. But then, the OP's question is ambiguous "in a given
directory" vs. "linux source directory".
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
Back to top
ellis
External


Since: Apr 02, 2004
Posts: 193



PostPosted: Thu Aug 02, 2007 11:49 pm    Post subject: Re: softlink [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <f8s0k9$v1$1@nntp.fujitsu-siemens.com>,
Josef Moellers <josef.moellers.TakeThisOut@fujitsu-siemens.com> wrote:

>TMTOWTDI
>
>for file in *
>do [ -L "$file" ] && rm -f "$file"
>done

That won't work if there are too many files in the
directory.

--
http://www.spinics.net/linux/fedora/fedora-users/
Back to top
Rainer Weikusat
External


Since: Apr 02, 2007
Posts: 105



PostPosted: Fri Aug 03, 2007 9:14 am    Post subject: Re: softlink [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

ellis.RemoveThis@no.spam () writes:
> In article <f8s0k9$v1$1@nntp.fujitsu-siemens.com>,
> Josef Moellers <josef.moellers.RemoveThis@fujitsu-siemens.com> wrote:
>
>>TMTOWTDI
>>
>>for file in *
>>do [ -L "$file" ] && rm -f "$file"
>>done
>
> That won't work if there are too many files in the
> directory.

Assuming the shell uses glob(3), it will not work if there isn't
enough memory available to hold the list of files.
Back to top
ellis
External


Since: Apr 02, 2004
Posts: 193



PostPosted: Fri Aug 03, 2007 10:40 pm    Post subject: Re: softlink [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <873az16qeo.fsf RemoveThis @fever.mssgmbh.com>,
Rainer Weikusat <rweikusat RemoveThis @mssgmbh.com> wrote:

>Assuming the shell uses glob(3), it will not work if there isn't
>enough memory available to hold the list of files.

The limit is a lot less than that. That's why find and xargs comes
in handy so often.

--
http://www.spinics.net/lists/kernel/
Back to top
Rainer Weikusat
External


Since: Apr 02, 2007
Posts: 105



PostPosted: Sun Aug 05, 2007 5:49 pm    Post subject: Re: softlink [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

ellis DeleteThis @no.spam () writes:
> In article <873az16qeo.fsf DeleteThis @fever.mssgmbh.com>,
> Rainer Weikusat <rweikusat DeleteThis @mssgmbh.com> wrote:
>
>>Assuming the shell uses glob(3), it will not work if there isn't
>>enough memory available to hold the list of files.
>
> The limit is a lot less than that.

It's always 'clever' to waive ones hands and mumble incomprehensible
syllables. This puts someone who may feel inclined to disagree in the
unfortunate position of having to guess at what was actually meant by
particular statement. Nevertheless, I am fairly confident that my
'guess' that you (erronously) see an ARG_MAX involved hear is correct.

According to SUS,

There shall be no limit on the size of any shell command other
than that imposed by the underlying system (memory
constraints, {ARG_MAX}, and so on).

And ARG_MAX shouldn't be relevant for shell for-loops.
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> System Development All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum