LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-13-2009, 08:41 PM   #1
shorte85
Member
 
Registered: Mar 2009
Posts: 47

Rep: Reputation: 15
What a command means...


I believe I understand what the command means, but putting it in simple words is what is getting me. The command I am working on is the following:

Code:
find */public_html –type d | cut –f 1 –d/ | uniq –c | sort –g | tail -5
Now this is what I have came up with as far as what each thing means in this command:

find = Search for files that meet a desired criteria

-type d = directory

cut = Divide a file into several parts

-f =are separated by a TAB character by default.

1 = parse out column 1

-d/ = ??

uniq = Uniquify files

-c = Print the number of times each line occurred along with the line.

sort = sort text files

-g = Sort numerically, using the standard C function `strtod' to convert a prefix of each line to a double-precision floating point number. - not sure what this means though...

tail -5 = Output the last N (number) lines.

I have ran this command in linux after issuing the
Code:
cd /home
command, and then issued
Code:
find */public_html –type d | cut –f 1 –d/ | uniq –c | sort –g | tail -5
to get a better understanding of it, to see what it looks like and see what it does. As far as I understand it, it lists off all users within crux and sort order, but a lot of them are Permission Denied so it doesn't exactly do the last 5 lines of a file. So I am definitely confused!!

Anyway someone could help me better understand this? I'd highly appreciate it.

-----

Also wanted to quickly add that I noticed that when I reran that command in linux that after it scans all users it has 5 lines that are completely different from the rest that it scans through that looks like the following:

628 userid
643 userid
673 userid
826 userid
1706 userid

So I'm assuming that would be the tail part of the command. Am I wrong about this or am I way off? Sheesh, I'm so confused with this command it's not even funny. lol

Last edited by shorte85; 03-13-2009 at 08:44 PM.
 
Old 03-13-2009, 09:03 PM   #2
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267

Rep: Reputation: 58
Think of all before a | as a command and the output of that command is the input to all that follows; and again ...
the -d/ in the cut command sets the field delimiter to /
see man cut
Yes the final 5 lines output come from the tail, but it is the tail of the sorted unique lines.
 
Old 03-13-2009, 09:23 PM   #3
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267

Rep: Reputation: 58
If you just wanted a fish instead of how to fish;
"list the five users with the most directories in their public_html directory (usually the place for users web pages) in ascending order please, Hal."

Or, simply, "Give me the five users with the most web pages, Hal, in ascending order"

Last edited by david1941; 03-13-2009 at 09:39 PM.
 
Old 03-13-2009, 09:44 PM   #4
shorte85
Member
 
Registered: Mar 2009
Posts: 47

Original Poster
Rep: Reputation: 15
Thanks so much for helping me with this, with you explaining in both posts and then I did the man cut in linux which helped as well. I also look on this site as a reference guide type thing as well: http://www.ss64.com/bash/ it helps from time to time because in some of the commands it gives examples and I try them out on linux which kind of help out on understanding things.

Again I appreciate you helping me out with this one. I think what confuses me is all the | between each command. It throws me a curb ball, and then I get all frustrated.

Now just to make sure I understand this correctly, here's a different but very similiar command:

Code:
find */public_html –type f | cut –f 1 –d/ | uniq –c | sort –g | tail -5
The only thing different is that it's looking for files and not directories. So it's listing the five users with the most files, right?

Last edited by shorte85; 03-13-2009 at 09:51 PM.
 
Old 03-13-2009, 10:07 PM   #5
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267

Rep: Reputation: 58
Correct. But it is still keying on the public_html directories, and any individual web page could have many or few files. I keep a lot of files on a page that are never sent but only used to generate files that are sent. I suppose it's a valid measure though. Have fun with this stuff; a shell command is a real time saver.
 
Old 03-13-2009, 10:09 PM   #6
shorte85
Member
 
Registered: Mar 2009
Posts: 47

Original Poster
Rep: Reputation: 15
Okay, cool!! Thanks for helping me out. That one was a little tough. I appreciate it!!

I am sure I will be back...
 
Old 03-13-2009, 10:10 PM   #7
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
A good way to figure out commands with this many pipes is to divide it up. By this I mean run the command up to the first pipe:
Code:
find */public_html –type f
Then run the part of the command up to the second pipe, etc:
Code:
find */public_html –type f | cut –f 1 –d/
That way you can compare the outputs to see what is going on.
 
Old 03-13-2009, 10:16 PM   #8
shorte85
Member
 
Registered: Mar 2009
Posts: 47

Original Poster
Rep: Reputation: 15
Hmm, I will definitely have to keep that in mind norobro!!! I'm going to give it a shot now to see what happens in linux.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command line option -F means what? TSynergy Linux - Newbie 5 11-15-2005 08:01 PM
Does anyone know what this means? mrchaos Slackware 8 04-23-2005 01:32 PM
what does it means dark_light Linux - General 1 07-18-2002 06:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration