自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

比man更強(qiáng)悍的命令行工具cheat

系統(tǒng) Linux
經(jīng)常使用命令行,比如 curl 測(cè)試接口響應(yīng)時(shí)間,奈何命令行參數(shù)太多,記不住怎么辦?這時(shí)候你需要個(gè)男人,它就是 man。

經(jīng)常使用命令行,比如 curl 測(cè)試接口響應(yīng)時(shí)間,

  1. for i in {1..10};do curl -o /dev/null -s   -w "$i | time_namelookup: %{time_namelookup} | time_connect: %{time_connect} | time_starttransfer: %{time_starttransfer} | time_total: %{time_total} 
  2. " "http://httpbin.org/ip";done 
  3.  
  4. 1 | time_namelookup: 0.016000 | time_connect: 0.016000 | time_starttransfer: 0.125000 | time_total: 0.141000 
  5. 2 | time_namelookup: 0.016000 | time_connect: 0.016000 | time_starttransfer: 0.094000 | time_total: 0.109000 
  6. 3 | time_namelookup: 0.016000 | time_connect: 0.031000 | time_starttransfer: 0.109000 | time_total: 0.109000 
  7. 4 | time_namelookup: 0.015000 | time_connect: 0.031000 | time_starttransfer: 0.109000 | time_total: 0.109000 
  8. 5 | time_namelookup: 0.031000 | time_connect: 0.031000 | time_starttransfer: 0.109000 | time_total: 0.109000 
  9. 6 | time_namelookup: 0.016000 | time_connect: 0.016000 | time_starttransfer: 0.094000 | time_total: 0.109000 
  10. 7 | time_namelookup: 0.016000 | time_connect: 0.016000 | time_starttransfer: 0.125000 | time_total: 0.125000 
  11. 8 | time_namelookup: 0.000001 | time_connect: 0.016000 | time_starttransfer: 0.141000 | time_total: 0.141000 
  12. 9 | time_namelookup: 0.015000 | time_connect: 0.015000 | time_starttransfer: 0.093000 | time_total: 0.109000 
  13. 10 | time_namelookup: 0.000001 | time_connect: 0.015000 | time_starttransfer: 0.109000 | time_total: 0.125000 

奈何命令行參數(shù)太多,記不住怎么辦?這時(shí)候你需要個(gè)男人,它就是 man。

man

  1. #man curl  
  2. curl(1)                                      Curl Manual                                     curl(1) 
  3.  
  4. NAME 
  5.        curl - transfer a URL 
  6.  
  7. SYNOPSIS 
  8.        curl [options] [URL...] 
  9.  
  10. DESCRIPTION 
  11.        curl  is  a  tool  to transfer data from or to a server, using one of the supported protocols 
  12.        (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP,  LDAPS,  POP3,  POP3S,  RTMP, 
  13.        RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP).  The command is designed to work without user 
  14.        interaction. 
  15.  
  16.        curl offers a busload of useful tricks like proxy support, user authentication,  FTP  upload, 
  17.        HTTP  post,  SSL  connections, cookies, file transfer resume, Metalink, and more. As you will 
  18.        see below, the number of features will make your head spin! 
  19.  
  20.        curl is powered by libcurl for all transfer-related features. See libcurl(3) for details. 
  21.  
  22. URL 
  23.        The URL syntax is protocol-dependent. You'll find a detailed description in RFC 3986. 
  24.  
  25.        You can specify multiple URLs or parts of URLs by writing part sets within braces as in
  26.  
  27.         http://site.{one,two,three}.com 
  28.  
  29.        or you can get sequences of alphanumeric series by using [] as in
  30.  
  31.         ftp://ftp.numericals.com/file[1-100].txt 
  32.         ftp://ftp.numericals.com/file[001-100].txt    (with leading zeros) 
  33.         ftp://ftp.letters.com/file[a-z].txt 

男人的確很強(qiáng)悍,給出了這么多提示,但沒有我真正想要的。。。還是不知道怎么用。

相信你在技術(shù)文章里經(jīng)常會(huì)看到 TL;DR 即Too Long; Didn’t Read. 太長(zhǎng)不看, man curl 的內(nèi)容就是太長(zhǎng)了,我不看。

就是這個(gè)更強(qiáng)壯的男人 tldr,它一個(gè)命令行工具,直接使用 npm install -g tldr 來(lái)安裝。

tldr

  1. [root@VM_0_14_centos ~]# npm install -g tldr 
  2. /usr/local/n/versions/node/11.4.0/bin/tldr -> /usr/local/n/versions/node/11.4.0/lib/node_modules/tldr/bin/tldr 
  3. + tldr@3.2.7 
  4. added 113 packages from 103 contributors in 60.759s 
  5.  
  6.  
  7.    ╭───────────────────────────────────────────────────────────────╮ 
  8.    │                                                               │ 
  9.    │       New minor version of npm available! 6.4.1 → 6.9.0       │ 
  10.    │   Changelog: https://github.com/npm/cli/releases/tag/v6.9.0   │ 
  11.    │               Run npm install -g npm to update!               │ 
  12.    │                                                               │ 
  13.    ╰───────────────────────────────────────────────────────────────╯ 

安裝完后先看看 tldr 自己怎么用吧。

  1. $ tldr tldr 
  2.  
  3.   tldr 
  4.  
  5.   Simplified man pages. 
  6.   More information: . 
  7.  
  8.   - Get typical usages of a command (hint: this is how you got here!): 
  9.     tldr command 
  10.  
  11.   - Show the tar tldr page for linux: 
  12.     tldr -p linux tar 
  13.  
  14.   - Get help for a git subcommand: 
  15.     tldr git checkout 

小試牛刀下

  1. $ tldr -p linux tar 
  2.  
  3.   tar 
  4.  
  5.   Archiving utility. 
  6.   Often combined with a compression method, such as gzip or bzip. 
  7.   More information: . 
  8.  
  9.   - Create an archive from files: 
  10.     tar -cf target.tar file1 file2 file3 
  11.  
  12.   - Create a gzipped archive: 
  13.     tar -czf target.tar.gz file1 file2 file3 
  14.  
  15.   - Extract an archive in a target directory: 
  16.     tar -xf source.tar -C directory 
  17.  
  18.   - Extract a gzipped archive in the current directory: 
  19.     tar -xzf source.tar.gz 
  20.  
  21.   - Extract a bzipped archive in the current directory: 
  22.     tar -xjf source.tar.bz2 
  23.  
  24.   - Create a compressed archive, using archive suffix to determine the compression program: 
  25.     tar -caf target.tar.xz file1 file2 file3 
  26.  
  27.   - List the contents of a tar file: 
  28.     tar -tvf source.tar 
  29.  
  30.   - Extract files matching a pattern: 
  31.     tar -xf source.tar --wildcards "*.html" 

嗯,很簡(jiǎn)潔,直接給出了tar需要的參數(shù),再來(lái)看curl

  1. λ tldr curl 
  2.  
  3.   curl 
  4.  
  5.   Transfers data from or to a server. 
  6.   Supports most protocols, including HTTP, FTP, and POP3. 
  7.  
  8.   - Download the contents of an URL to a file: 
  9.     curl http://example.com -o filename 
  10.  
  11.   - Download a file, saving the output under the filename indicated by the URL: 
  12.     curl -O http://example.com/filename 
  13.  
  14.   - Download a file, following [L]ocation redirects, and automatically [C]ontinuing (resuming) a previous file transfer: 
  15.     curl -O -L -C - http://example.com/filename 
  16.  
  17.   - Send form-encoded data (POST request of type application/x-www-form-urlencoded): 
  18.     curl -d 'name=bob' http://example.com/form 
  19.  
  20.   - Send a request with an extra header, using a custom HTTP method: 
  21.     curl -H 'X-My-Header: 123' -X PUT http://example.com 
  22.  
  23.   - Send data in JSON format, specifying the appropriate content-type header: 
  24.     curl -d '{"name":"bob"}' -H 'Content-Type: application/json' http://example.com/users/1234 
  25.  
  26.   - Pass a user name and password for server authentication: 
  27.     curl -u myusername:mypassword http://example.com 
  28.  
  29.   - Pass client certificate and key for a resource, skipping certificate validation: 
  30.     curl --cert client.pem --key key.pem --insecure https://example.com 

這個(gè)男人果然更強(qiáng)悍,常用的curl命令都包括了,我喜歡。

除了自帶的命令,安裝的命令也可以

  1. [root@VM_0_14_centos ~]# tldr python 
  2.  
  3.   python 
  4.  
  5.   Python language interpreter. 
  6.   More information: https://www.python.org. 
  7.  
  8.   - Call a Python interactive shell (REPL): 
  9.     python 
  10.  
  11.   - Execute script in a given Python file: 
  12.     python script.py 
  13.  
  14.   - Execute script as part of an interactive shell: 
  15.     python -i script.py 
  16.  
  17.   - Execute a Python expression: 
  18.     python -c "expression" 
  19.  
  20.   - Run library module as a script (terminates option list): 
  21.     python -m module arguments 
  22.  
  23.   - Interactively debug a Python script: 
  24.     python -m pdb script.py 

除了node 還有其他版本 https://github.com/tldr-pages/tldr

比如Python,直接pip install tldr安裝。

如果你不想安裝tldr,也可以直接使用網(wǎng)頁(yè)在線查看https://tldr.sh/

 

 

 

有了tldr,媽媽再也不用擔(dān)心我記不住命令行參數(shù)了,還有沒有比 tldr更強(qiáng)悍的男人呢,有,比如cheat https://github.com/cheat/cheat ,直接使用pip install cheat安裝。

cheat

看看 cheat 怎么用吧

  1. $ cheat cheat 
  2. To see example usage of a program: 
  3. cheat <command> 
  4.  
  5. To edit a cheatsheet 
  6. cheat -e <command> 
  7.  
  8. To list available cheatsheets 
  9. cheat -l 
  10.  
  11. To search available cheatsheets 
  12. cheat -s <command> 
  13.  
  14. To get the current `cheat' version 
  15. cheat -v 

試試 curl

  1. $ cheat curl 
  2. # Download a single file 
  3. curl http://path.to.the/file 
  4.  
  5. # Download a file and specify a new filename 
  6. curl http://example.com/file.zip -o new_file.zip 
  7.  
  8. # Download multiple files 
  9. curl -O URLOfFirstFile -O URLOfSecondFile 
  10.  
  11. # Download all sequentially numbered files (1-24) 
  12. curl http://example.com/pic[1-24].jpg 
  13.  
  14. # Download a file and pass HTTP Authentication 
  15. curl -u username:password URL 
  16.  
  17. # Download a file with a Proxy 
  18. curl -x proxysever.server.com:PORT http://addressiwantto.access 
  19.  
  20. # Download a file from FTP 
  21. curl -u username:password -O ftp://example.com/pub/file.zip 
  22.  
  23. # Get an FTP directory listing 
  24. curl ftp://username:password@example.com 
  25.  
  26. # Resume a previously failed download 
  27. curl -C - -o partial_file.zip http://example.com/file.zip 
  28.  
  29. Fetch only the HTTP headers from a response 
  30. curl -I http://example.com 
  31.  
  32. Fetch your external IP and network info as JSON 
  33. curl http://ifconfig.me/all/json 
  34.  
  35. # Limit the rate of a download 
  36. curl --limit-rate 1000B -O http://path.to.the/file 
  37.  
  38. # Get your global IP 
  39. curl httpbin.org/ip 
  40.  
  41. # Get only the HTTP status code 
  42. curl -o /dev/null -w '%{http_code} 
  43. ' -s -I URL 

比tldr更詳細(xì),如果你也不想安裝可以直接使用curl

cht.sh

  1. [root@VM_0_14_centos ~]# curl cht.sh/curl 
  2. # Download a single file 
  3. curl http://path.to.the/file 
  4.  
  5. # Download a file and specify a new filename 
  6. curl http://example.com/file.zip -o new_file.zip 
  7.  
  8. # Download multiple files 
  9. curl -O URLOfFirstFile -O URLOfSecondFile 
  10.  
  11. # Download all sequentially numbered files (1-24) 
  12. curl http://example.com/pic[1-24].jpg 
  13.  
  14. # Download a file and follow redirects 
  15. curl -L http://example.com/file 
  16.  
  17. # Download a file and pass HTTP Authentication 
  18. curl -u username:password URL 
  19.  
  20. # Download a file with a Proxy 
  21. curl -x proxysever.server.com:PORT http://addressiwantto.access 
  22.  
  23. # Download a file from FTP 
  24. curl -u username:password -O ftp://example.com/pub/file.zip 
  25.  
  26. # Get an FTP directory listing 
  27. curl ftp://username:password@example.com 
  28.  
  29. # Resume a previously failed download 
  30. curl -C - -o partial_file.zip http://example.com/file.zip 
  31.  
  32. Fetch only the HTTP headers from a response 
  33. curl -I http://example.com 
  34.  
  35. Fetch your external IP and network info as JSON 
  36. curl http://ifconfig.me/all/json 
  37.  
  38. # Limit the rate of a download 
  39. curl --limit-rate 1000B -O http://path.to.the/file 
  40.  
  41. # POST to a form 
  42. curl -F "name=user" -F "password=test" http://example.com 
  43.  
  44. # POST JSON Data 
  45. curl -H "Content-Type: application/json" -X POST -d '{"user":"bob","pass":"123"}' http://example.com 
  46.  
  47. # POST data from the standard in / share data on sprunge.us 
  48. curl -F 'sprunge=<-' sprunge.us 

看看Python的requests怎么用

  1. [root@VM_0_14_centos ~]# curl cheat.sh/python/requests 
  2. #  python-requests: Limit Number of Redirects Followed 
  3. #  You have to create Session (http://www.python- 
  4. #  requests.org/en/latest/api/requests.Session) object and set 
  5. #  max_redirects variable to 3 
  6.  
  7. session = requests.Session() 
  8. session.max_redirects = 3 
  9. session.get(url) 
  10.  
  11. #  TooManyRedirects exception will be raised if a requests exceeds 
  12. #  maximum number of redirects. 
  13. #  Related github issue discussing why you can not set max_redirects per 
  14. #  request https://github.com/kennethreitz/requests/issues/1300 
  15. #  [Alik] [so/q/31552627] [cc by-sa 3.0] 

它也有網(wǎng)頁(yè)版 http://cht.sh/curl

 

 

 

 

有了tldr和cheat,再也不用記那么多命令行參數(shù)了。

win下執(zhí)行命令行的工具我常用cmder,如果你用的win10,可以嘗試下微軟最新發(fā)布的Terminal https://github.com/microsoft/Terminal 

責(zé)任編輯:龐桂玉 來(lái)源: Linux學(xué)習(xí)
相關(guān)推薦

2024-09-29 13:25:56

2020-12-10 16:16:08

工具代碼開發(fā)

2020-12-11 06:44:16

命令行工具開發(fā)

2011-01-18 19:11:26

Postfix命令行

2023-06-09 07:45:29

Kuberneteskubectl

2013-11-15 09:43:15

JDK工具

2010-11-24 17:12:17

MySQL命令行

2013-12-09 14:29:13

OpenStack命令行工具API

2010-02-04 15:17:48

Linux wget

2017-06-15 10:32:56

OracleDBV命令行工具

2018-04-03 13:50:27

Linux容器命令行工具

2013-05-21 14:58:08

系統(tǒng)監(jiān)視glances開源

2015-07-01 09:15:46

linuxQuora命令行

2018-05-04 09:15:35

PythonPlumbum命令行

2019-08-27 10:32:01

Linux操作系統(tǒng)Windows

2020-12-10 10:40:38

DNS命令行工具Linux

2018-12-17 10:30:34

Linux命令行boxes

2020-03-30 12:57:50

Linux命令行Markdown

2010-08-24 09:10:14

Linux命令行工具

2014-07-31 10:09:12

Linux命令歸檔工具
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)