Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <01C10F7F.E11E3100.jorgens@coho.net> From: Steve Jorgensen Reply-To: "jorgens AT coho DOT net" To: "cygwin AT cygwin. Com (E-mail)" Subject: RE: Problem dereferencing with ls -L Date: Wed, 18 Jul 2001 11:50:38 -0700 X-Mailer: Microsoft Internet E-mail/MAPI - 8.0.0.4211 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 AT dev DOT tivoli DOT com] Sent: Wednesday, July 18, 2001 6:26 AM To: jorgens AT coho DOT net Subject: Re: Problem dereferencing with ls -L On 17 July 2001 at 14:50, Steve Jorgensen 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 -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 AT dev DOT tivoli DOT com] > Sent: Tuesday, July 17, 2001 2:16 PM > To: cygwin AT cygwin DOT com; jorgens AT coho DOT net > Subject: Re: Problem dereferencing with ls -L > > On 17 July 2001 at 14:02, Steve Jorgensen 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 DOT Heyman AT tivoli DOT 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/