Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Command that displays owner of a file?

    I'm writing a script that searches user's files for IP addresses, and I'm trying to find a way to display the owner of the file.

  2. #2
    Administrator jayd512's Avatar
    Join Date
    Feb 2008
    Hello and Welcome!

    What about just using ls?
    Using either the -l or -o options will display the owner.

    New users, read this first.
    New Member FAQ
    Registered Linux User #463940
    I do not respond to private messages asking for Linux help. Please keep it on the public boards.

  3. #3
    I was kind of hoping for a way to display
     Owner of File: "owner"
    Without all of the other stuff that ls -l displays. Also, if I'm looking at a particular file with IP addresses, will ls still work, or will it just display everything in that particular directory?

  4. $spacer_open
  5. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Something like this?
    egrep -Hr '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}' * | cut -d ":" -f1 | sort | uniq | xargs -L 10 stat -c "%U %n"
    Note: %U needs a valid name in /etc/passwd. In doubt, use %u

    Note2: Yes, I know that the regex is not exact. Sue me
    You must always face the curtain with a bow.

  6. #5
    thanks for that. It looks a lot like the cut that I was working on, but just couldn't get right.

  7. #6
    here's the part of the script I need help on
    dirs=$(ls $crank)
    oof=`echo ls -o | cut -c 14-`
    for user in "$crank"/*; do
             echo Username: "$oof"
             echo -e "\nPath: $user"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts