All of the above are correct, but not only do you need to look up the man for your new commands, but you really need to go and look at the man for cut as your very first example and explanation
are completely wrong.
I think the funny thing is that all the commands and files for your examples exist in all distributions so you could literally run each part of each command until you have the whole line and get
a very good understanding of exactly what the commands are doing.
As you seem to not understand what everyone is saying (maybe because English is not your first language), I'll break it down for you:
Before looking at either example, you will need to man bash and search for (using /) Pipelines, which will explain what the | symbol is doing.
1. man cut and specifically look at what the -d and -f options are for as your current understanding is wrong
2. Open the file /etc/passwd in an editor and look at the entries so you have a before comparison
3. Execute only the cut portion of the code and review the output and compare to what you saw above (or even better yet have the file open in an editor and then run command so you can see differences):
cut -d: -f1,6 /etc/passwd
4. man tr and get an understanding of SET1 and SET2. For your example SET1 is the colon (
and SET2 is a space
5. Execute up to tr command and compare to step 3:
cut -d: -f1,6 /etc/passwd | tr : ' '
6. man sort and read the description. You may also wish to google some examples
7. Execute the entire command and compare last output to that of step 5:
cut -d: -f1,6 /etc/passwd | tr : ' ' | sort
Next piece of code:
1. man last as your current understanding is incorrect
2. Execute last and inspect the output
3. man grep (this covers grep, egrep and fgrep) and specifically look at the -v option as your current understanding is wrong and is seriously point you in a bad direction for the results
4. Look up regular expressions as your current understanding of $ is wrong (here
is a start and you will want to look up anchors)
5. Execute each egrep in turn to compare the output to step 2:
last | egrep -v '^wtmp'
last | egrep -v '^wtmp' | egrep -v '^$'
6. Execute up to first sort (one then the other and compare to step 5 output) as you have already learned about cut and sort in above example:
last | egrep -v '^wtmp' | egrep -v '^$' | cut -f1 -d' '
last | egrep -v '^wtmp' | egrep -v '^$' | cut -f1 -d' ' | sort
7. man uniq and review the information on the -c switch as well as the description
8. Execute up to uniq and review output compared to step 6:
last | egrep -v '^wtmp' | egrep -v '^$' | cut -f1 -d' ' | sort | uniq -c
9. Review the man page for sort and look at the specific switches -n and -r
10. Execute and compare to output in step 8:
last | egrep -v '^wtmp' | egrep -v '^$' | cut -f1 -d' ' | sort | uniq -c | sort -nr
In case you were wondering, this is how all the other users here have learned and as you will see this takes some time, which is why everyone is upset that you are not making any effort
when we all had to and you just want to get the benefit of our hard work.