Unix ls command: show full path when using options

前端 未结 8 1680
故里飘歌
故里飘歌 2020-12-07 12:13

I often use this list command in Unix (AIX / KSH):

ls -Artl

It displays the files as this:

-rw-r--r-- 1 myuser mygroup 0 Apr 2

相关标签:
8条回答
  • 2020-12-07 12:36

    Use this command:

    ls -ltr /mig/mthome/09/log/*
    

    instead of:

    ls -ltr /mig/mthome/09/log
    

    to get the full path in the listing.

    0 讨论(0)
  • 2020-12-07 12:42

    I use this command:

    ls -1 | xargs readlink -f
    
    0 讨论(0)
  • 2020-12-07 12:42

    You can combine the find command and the ls command. Use the path (.) and selector (*) to narrow down the files you're after. Surround the find command in back quotes. The argument to -name is doublequote star doublequote in case you can't read it.

    ls -lart `find . -type f -name "*" `
    
    0 讨论(0)
  • 2020-12-07 12:47

    Try this, works for me: ls -d /a/b/c/*

    0 讨论(0)
  • 2020-12-07 12:48

    I wrote a shell script called fullpath that contains this code, use it everyday:

        #!/bin/sh
        for i in $* ; do
            echo $(pwd)/$i
        done
    

    Put it somewhere in your PATH, and make it executable(chmod 755 fullpath) then just use
    fullpath file_or_directory

    0 讨论(0)
  • 2020-12-07 12:52

    optimized from spacedrop answer ...

    ls $(pwd)/*
    

    and you can use ls options

    ls -alrt $(pwd)/*
    
    0 讨论(0)
提交回复
热议问题