Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display only files and folders that are symbolic links in tcsh or bash

Basically I want do the following:

ls -l[+someflags] 

(or by some other means) that will only display files that are symbolic links

so the output would look

-rw-r--r--  1 username grp   size date-time    filename -> somedir -rw-r--r--  1 username grp   size date-time    filename2 -> somsdfsdf 

etc.

For example,

to show only directories I have an alias:

alias  lsd  'ls -l | grep ^d' 

I wonder how to display only hidden files or only hidden directories?

I have the following solution, however it doesn't display the output in color :(

ls -ltra | grep '\->' 
like image 628
vehomzzz Avatar asked Sep 11 '09 18:09

vehomzzz


People also ask

How do I view a symbolic link in bash?

Your Bash script might need to determine if a file is a symlink or not. In Bash you can test this with the -L operator that returns true if the file exists and is a symlink.

How do I find symbolic link files in Linux?

Simplest way: cd to where the symbolic link is located and do ls -l to list the details of the files. The part to the right of -> after the symbolic link is the destination to which it is pointing.


1 Answers

Find all the symbolic links in a directory:

ls -l `find /usr/bin -maxdepth 1 -type l -print` 

For the listing of hidden files:

ls -ald .* 
like image 116
ChristopheD Avatar answered Sep 21 '22 14:09

ChristopheD