Results 1 to 6 of 6
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....
- 09-18-2011 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 4
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.
- 09-18-2011 #2
Hello and Welcome!
What about just using ls?
Using either the -l or -o options will display the owner.Jay
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.
- 09-19-2011 #3Just Joined!
- Join Date
- Sep 2011
- Posts
- 4
I was kind of hoping for a way to display
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?Code:Owner of File: "owner"
- 09-19-2011 #4
Something like this?
Note: %U needs a valid name in /etc/passwd. In doubt, use %uCode:cd <DIRECTORY_WITH_THE_FILES> egrep -Hr '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}' * | cut -d ":" -f1 | sort | uniq | xargs -L 10 stat -c "%U %n"
Note2: Yes, I know that the regex is not exact. Sue me
You must always face the curtain with a bow.
- 09-20-2011 #5Just Joined!
- Join Date
- Sep 2011
- Posts
- 4
thanks for that. It looks a lot like the cut that I was working on, but just couldn't get right.
- 09-20-2011 #6Just Joined!
- Join Date
- Sep 2011
- Posts
- 4
here's the part of the script I need help on
Code:hammer=/home dirs=$(ls $crank) oof=`echo ls -o | cut -c 14-` for user in "$crank"/*; do echo Username: "$oof" echo -e "\nPath: $user"


Reply With Quote