public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: Problem dereferencing with ls -L
@ 2001-07-18 11:41 Steve Jorgensen
  0 siblings, 0 replies; 3+ messages in thread
From: Steve Jorgensen @ 2001-07-18 11:41 UTC (permalink / raw)
  To: cygwin@cygwin. Com (E-mail)

As long as I'm doing this here, I guess I didn't communicate precisely 
enough what I'm trying to do.  I want a list of files where any regular 
entries show as normal, but any symlinks show only the target.  As for 
find, the printf option definitely can show both the file name and the 
symlink target only if there is one.  That would just leave me having to 
remove the symlink name from the output that had both so I was left with 
only the target in those cases.

When I sit down to look at it again, I bet I can use sed for the second 
part.  I think I'll get it.  I had just thought ls could do it for me 
without having to roll my own.

-----Original Message-----
From:	(Jerry Heyman) [SMTP:jerry@dev.tivoli.com]
Sent:	Wednesday, July 18, 2001 6:26 AM
To:	jorgens@coho.net
Subject:	Re: Problem dereferencing with ls -L

On 17 July 2001 at 14:50, Steve Jorgensen <jorgens@coho.net> wrote:
> OK, sorry.  I thought this was a Cygwin issue, but it really seems to be 
a
> "me not knowing the *nix toolset very well" problem.

No problem.

> I thought that ls -L
> would show me the name of the file pointed to if the file was a symlink.

Nope, that's the -l option.

> Of course, I still don't know any simple way to do what I'm looking for.
> find -printf can output just the symlinked file name, but then it will be 
> blank if the file is not a symlink, so guess I might have to -printf a
> string with both parts and do additional processing to distinguish the 2
> cases - I guess I gould pipe through sed or something.

find is a very powerful command with many options.  To list only the
files that are symlinks, you could do:

find <directory name> -type l -print

That will only print the files that are symlinked to other files.  Of
course, it sounds like what you'd like is the name of the file AND the
file that its linked to.  I'm not aware of any one command that can do
that, but you could always create a pipelined expression - possibly
using find, combined with ls and awk - or you could always write your
own tool - on that uses the stat() function.

> Sorry to ask this in this list.  I'll avoid this kind of thing in the
> future.  Any good *nix shell tips, tricks, and examples sites?

No problem, that's what the list is for.  You'd be surprised what else
gets posted.  Someone even complained last week that the setup.exe was
actually a virus that corrupted his/her machine!

As for websites, you could try a google search.  I just did one looking
for 'shell script examples' and came up with LOTS of different locations
that have examples of different scripts.

Its a whole new world out there once you start playing with the power
of the Unix shell commands.

jerry

>
> -----Original Message-----
> From:	(Jerry Heyman) [SMTP:jerry@dev.tivoli.com]
> Sent:	Tuesday, July 17, 2001 2:16 PM
> To:	cygwin@cygwin.com; jorgens@coho.net
> Subject:	Re: Problem dereferencing with ls -L
>
> On 17 July 2001 at 14:02, Steve Jorgensen <jorgens@coho.net> wrote:
> > When I run ls -L /usr/bin/awk, I get /usr/bin/awk.  Similarly, if I 
enter
> > ls -L /usr/bin/awk.exe, I get /usr/bin/awk.exe.  If, however, I enter 
ls
> -l
> > /usr/bin/awk, it tells me that /usr/bin/awk -> gawk.exe.  Why doesn't 
ls
> -L
> > show me the dereferenced file info?
>
> Unless I misunderstand the question, the -L flag says follow any
> symlinks and show me the file that I've requested.  Which means that
> if foo is symlinked to bar and you do an:
>
> ls -L foo
>
> You will see foo on the output
>
> -l is the long listing and if its a symlink will tell you what the
> link is pointing to.  If you do:
>
> ls -lL /usr/bin/*awk*
>
> You should see all the different names for awk in the directory and
> their size/date will all be the same, because they are actually giving
> you the size of the same file.
>
> jerry
--
Jerry Heyman   919.224.1442    | Tivoli Systems       |"Software is the
Build Infrastructure Architect | 3901 S Miami Blvd    | difference between
Jerry.Heyman@tivoli.com        | Durham, NC  27703    | hardware and 
reality"
                          http://www.acm.org/~heymanj



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problem dereferencing with ls -L
  2001-07-17 13:53 Steve Jorgensen
@ 2001-07-17 14:15 ` jerry
  0 siblings, 0 replies; 3+ messages in thread
From: jerry @ 2001-07-17 14:15 UTC (permalink / raw)
  To: cygwin, jorgens

On 17 July 2001 at 14:02, Steve Jorgensen <jorgens@coho.net> wrote:
> When I run ls -L /usr/bin/awk, I get /usr/bin/awk.  Similarly, if I enter 
> ls -L /usr/bin/awk.exe, I get /usr/bin/awk.exe.  If, however, I enter ls -l 
> /usr/bin/awk, it tells me that /usr/bin/awk -> gawk.exe.  Why doesn't ls -L 
> show me the dereferenced file info?

Unless I misunderstand the question, the -L flag says follow any
symlinks and show me the file that I've requested.  Which means that
if foo is symlinked to bar and you do an:

ls -L foo

You will see foo on the output

-l is the long listing and if its a symlink will tell you what the
link is pointing to.  If you do:

ls -lL /usr/bin/*awk*

You should see all the different names for awk in the directory and
their size/date will all be the same, because they are actually giving
you the size of the same file.

jerry
-- 
Jerry Heyman   919.224.1442    | Tivoli Systems       |"Software is the 
Build Infrastructure Architect | 3901 S Miami Blvd    | difference between
Jerry.Heyman@tivoli.com        | Durham, NC  27703    | hardware and reality"
                          http://www.acm.org/~heymanj



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Problem dereferencing with ls -L
@ 2001-07-17 13:53 Steve Jorgensen
  2001-07-17 14:15 ` jerry
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Jorgensen @ 2001-07-17 13:53 UTC (permalink / raw)
  To: cygwin@cygwin. Com (E-mail)

When I run ls -L /usr/bin/awk, I get /usr/bin/awk.  Similarly, if I enter 
ls -L /usr/bin/awk.exe, I get /usr/bin/awk.exe.  If, however, I enter ls -l 
/usr/bin/awk, it tells me that /usr/bin/awk -> gawk.exe.  Why doesn't ls -L 
show me the dereferenced file info?

Thanks...

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-07-18 11:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-18 11:41 Problem dereferencing with ls -L Steve Jorgensen
  -- strict thread matches above, loose matches on Subject: below --
2001-07-17 13:53 Steve Jorgensen
2001-07-17 14:15 ` jerry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).