sort
I cant understand the code below.I know what it does sort ,but when it is alone i mean it hasnt after something,i have no idea nor i find something in any book not even in google.Can someone give a good explanation to this line because i cant understand it.What i know to help cut is read the entrance and give the result to exit. After it refers to direcory to a file line 1 until 6 and read the archive etc passwd.Translate the empty.Thanks a lot
cut -d: -f1,6 /etc/passwd | tr : ' ' | sort |
help me please
explain this line please.
last searching the user that make the last mounth login. egrep -v '^wtmp' = search starting with wtmp . egrep -v '^$'=egrep search first starting with $ .I think refers to variable cut -f1 -d ' ' = refers to file first line to directory and after empty sort = make sort.. uniq -c= sort -nr = last |egrep -v '^wtmp' | egrep -v '^$'| cut -f1 -d' '| sort| uniq -c|sort -nr |
have you already seen the posting rules of LQ? http://www.catb.org/%7Eesr/faqs/smart-questions.html
have you checked man uniq (especially the flag -c) have you checked man sort already? |
Quote:
|
The output of the first program is fed into the next one using a pipe ( | ) and it goes from left to right through the chain. So at each step, you'll need to look up the man pages as suggested above earlier.
Code:
man uniq |
|
This appears to be more of this:
http://www.linuxquestions.org/questi...me-4175581794/ http://www.linuxquestions.org/questi...se-4175581964/ Here's an idea - rather than spin your wheels asking everyone to explain something someone else wrote for you that you can't understand, go back to the actual question, take it step by step, and learn about what you're supposed to do. Then do it. Ask questions only when you've exhausted all resources, and you have something specific to ask. Or if you want to continue having someone else do your homework, go back to the person that originally wrote this for you. No one here is going to give you direct answers, only point you in a direction to LEARN about what you need to know (which they already have, in abundance). If you don't want to learn, then maybe you shouldn't have taken the course. |
Quote:
i'm sure this could be coded nicer. as was said before, look at the man pages of each command. what i also like to do with these monsters: i execute them once as is, then i delete everything until and including the last pipe, see what that gives me, and proceed so on until i get to the first command. |
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. First example: 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): Code:
cut -d: -f1,6 /etc/passwd 5. Execute up to tr command and compare to step 3: Code:
cut -d: -f1,6 /etc/passwd | tr : ' ' 7. Execute the entire command and compare last output to that of step 5: Code:
cut -d: -f1,6 /etc/passwd | tr : ' ' | sort 1. man last as your current understanding is incorrect 2. Execute last and inspect the output Code:
last 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: Code:
last | egrep -v '^wtmp' Code:
last | egrep -v '^wtmp' | egrep -v '^$' Code:
last | egrep -v '^wtmp' | egrep -v '^$' | cut -f1 -d' ' 8. Execute up to uniq and review output compared to step 6: Code:
last | egrep -v '^wtmp' | egrep -v '^$' | cut -f1 -d' ' | sort | uniq -c 10. Execute and compare to output in step 8: Code:
last | egrep -v '^wtmp' | egrep -v '^$' | cut -f1 -d' ' | sort | uniq -c | sort -nr when we all had to and you just want to get the benefit of our hard work. |
All times are GMT -5. The time now is 11:43 AM. |