How to display a list of recent commands in Ubuntu Linux Kā lai parādītu sarakstu ar nesen komandas Ubuntu Linux
Linux has a rich command line experience that can sometimes be a little daunting for people switching over from Windows. Linux ir bagāta komandrindas pieredze dažkārt var būt nedaudz biedējošu cilvēkiem pāreju no Windows. Displaying the list of recent commands is pretty simple, though: Displaying saraksts pēdējo komandu ir diezgan vienkārša, tomēr:
> history > Vēsture
1 ps -ef 1 ps-ef
2 kill 24188 2 nogalināt 24.188
3 ps -ef 3 ps-ef
4 tail logfile.log 4 asti logfile.log
If you want to find a command that you used before but you have a huge history list, you can quickly find it by passing it through grep. Ja jūs vēlaties atrast komandu, kuru izmantojāt iepriekš, bet jums ir milzīgs vēstures sarakstu, jūs varat ātri atrast, laižot to caur grep. Let's say we remember typing the ftp command, but can't remember the domain name of the server: Let's say mēs atceramies rakstīt ftp komandu, bet nevar atcerēties domēna vārdu serveris:
> history | grep ftp > Vēsture | grep ftp
321 ftp 321 ftp ftp.cdrom18.com ftp.cdrom18.com
Pretty simple stuff! Diezgan vienkāršs stuff! What if we want to display the list of items that we use the most often? We can use a much more complicated command like this: Ko darīt, ja mēs vēlamies parādīt posteņu sarakstu, ko mēs izmantojam visbiežāk? Mēs varam izmantot daudz sarežģītāka komandu, piemēram, šādi:
> history|awk '{print $2}'|awk 'BEGIN {FS=”|”} {print $1}'|sort|uniq -c|sort -r > History | awk '(print $ 2)' | awk 'BEGIN (FS ="|"} (print $ 1)' | sort | uniq-c | sort-r
114 ls 114 ls
105 ./runreports.sh 105. / Runreports.sh
97 cd 97 cd
24 uptime 24 uptime
15 mysql 15 mysql
13 vi 13 vi
The last command was thanks to Pēdējā komanda bija pateicoties Lifehacker Lifehacker , which is a great site you should definitely subscribe to. , Kas ir lieliska vieta jums noteikti vajadzētu abonēt.
The techniques used in the last command are useful in other contexts. Metodēm, ko izmanto pēdējā komanda ir noderīgi citos kontekstos. I'll be posting more similar commands going forwards. I'll be Sludinājuma vairāk līdzinās komandas iet uz priekšu.

Daily Email Updates Daily Email Updates
You can get our how-to articles in your inbox each day for free. Jūs varat saņemt mūsu how-to rakstus savā pastkastītē katru dienu par brīvu. Just enter your name and email below: Vienkārši ievadiet jūsu vārdu un e-pasta zemāk:



This is a bash builtin . Tas ir bash iebūvēto. man bash and the builtin manual pops up showing history in there. vīrietis bash un builtin rokasgrāmata POP parāda, vēsturi tur.
-N -N