List file using ls command in Linux with full path

前端 未结 13 1677
星月不相逢
星月不相逢 2020-12-24 01:02

Many will found that this is repeating questions but i have gone through all the questions before asked about this topic but none worked for me.

I want to print full

13条回答
  •  萌比男神i
    2020-12-24 01:28

    For listing everything with full path, only in current directory

    find $PWD -maxdepth 1
    

    Same as above but only matches a particular extension, case insensitive (.sh files in this case)

    find $PWD -maxdepth 1 -iregex '.+\.sh'
    

    $PWD is for current directory, it can be replaced with any directory

    mydir="/etc/sudoers.d/" ; find $mydir -maxdepth 1
    

    maxdepth prevents find from going into subdirectories, for example you can set it to "2" for listing items in children as well. Simply remove it if you need it recursive.

    To limit it to only files, can use -type f option.

    find $PWD -maxdepth 1 -type f
    

提交回复
热议问题