List file using ls command in Linux with full path

前端 未结 13 1622
星月不相逢
星月不相逢 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:29

    You could easily use the following to list only files:

    ls -d -1 $PWD/*.*
    

    the following to list directories:

    ls -d -1 $PWD/**
    

    the following to list everything (files/dirs):

    ls -d -1 $PWD/**/*
    

    More helpful options:

    -d list directories not their content

    -R recursive

    -1 list one file per line

    -l use long listing format

    -a list all including entries starting with . and ..

    -A list all but don't list implied . and ..

    for more info, just type the following

    ls --help 
    
    0 讨论(0)
  • 2020-12-24 01:31

    I have had this issue, and I use the following :

    ls -dl $PWD/* | grep $PWD

    It has always got me the listingI have wanted, but your mileage may vary.

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

    Print the full path (also called resolved path) with:

    realpath README.md
    

    In interactive mode you can use shell expansion to list all files in the directory with their full paths:

    realpath *
    

    If you're programming a bash script, I guess you'll have a variable for the individual file names.

    Thanks to VIPIN KUMAR for pointing to the related readlink command.

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

    There is more than one way to do that, the easiest I think would be:

    find /mnt/mediashare/net/192.168.1.220_STORAGE_1d1b7
    

    also this should work:

    (cd /mnt/mediashare/net/192.168.1.220_STORAGE_1d1b7; ls | xargs -i echo `pwd`/{})
    
    0 讨论(0)
  • 2020-12-24 01:37

    try this -

    readlink -f file.txt

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

    This worked for me:

    ls -rt -d -1 $PWD/{*,.*}
    
    0 讨论(0)
提交回复
热议问题