List file using ls command in Linux with full path

前端 未结 13 1621
星月不相逢
星月不相逢 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条回答
  • 2020-12-24 01:18

    This prints all files, recursively, from the current directory.

    find "$PWD" | awk /.ogg/ # filter .ogg files by regex
    find "$PWD" | grep .ogg  # filter .ogg files by term
    find "$PWD" | ack .ogg   # filter .ogg files by regex/term using https://github.com/petdance/ack2
    
    0 讨论(0)
  • 2020-12-24 01:23

    How about:

     du -a [-b] [--max-depth=N] 
    

    That should give you a file and directory listing, relative to your current location. You will get sizes as well (add the '-b' parameter if you want the sizes in bytes). The max-depth parameter may be necessary to "encourage" du to dive deeply enough into your file structure -- or to keep it from getting carried away.

    YMMV!
    -101-

    0 讨论(0)
  • 2020-12-24 01:25

    You can use

      ls -lrt -d -1 "$PWD"/{*,.*}   
    

    It will also catch hidden files.

    0 讨论(0)
  • 2020-12-24 01:26

    You can try this:

    ls -d $PWD/*
    
    0 讨论(0)
  • 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
    
    0 讨论(0)
  • 2020-12-24 01:28

    The ls command will only print the name of the file in the directory. Why not do something like

    print("/mnt/mediashare/net/192.168.1.220_STORAGE_1d1b7/" + i)

    This will print out the directory with the filename.

    0 讨论(0)
提交回复
热议问题