简体   繁体   中英

find command to list symbolic link files not working in bash script

bash script

Im trying to make a script that lists all symbolic link files in a directory but the command im using doesnt seem to work in the script but works when i use it in the terminal.

result

You can try these options and see what fits to your need best.

Pseudo code:

   #!/usr/bin/bash
    find . -type l -ls
    #To only process the current directory:
    #find . -maxdepth 1 -type l -ls

More find commands to list symbolic link in dir:

find -L /dir/to/start -xtype l -samefile ~/Pictures 2>/dev/null.
find / -lname /path/to/original/dir
  • L - Follow symbolic links.
  • xtype l - File is symbolic link
  • samefile name - File refers to the same inode as name. When -L is in effect, this can include symbolic links.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM