成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

比man更強悍的命令行工具cheat

系統 Linux
經常使用命令行,比如 curl 測試接口響應時間,奈何命令行參數太多,記不住怎么辦?這時候你需要個男人,它就是 man。

經常使用命令行,比如 curl 測試接口響應時間,

  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 

奈何命令行參數太多,記不住怎么辦?這時候你需要個男人,它就是 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 

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

相信你在技術文章里經常會看到 TL;DR 即Too Long; Didn’t Read. 太長不看, man curl 的內容就是太長了,我不看。

就是這個更強壯的男人 tldr,它一個命令行工具,直接使用 npm install -g tldr 來安裝。

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" 

嗯,很簡潔,直接給出了tar需要的參數,再來看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 

這個男人果然更強悍,常用的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,也可以直接使用網頁在線查看https://tldr.sh/

 

 

 

有了tldr,媽媽再也不用擔心我記不住命令行參數了,還有沒有比 tldr更強悍的男人呢,有,比如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更詳細,如果你也不想安裝可以直接使用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] 

它也有網頁版 http://cht.sh/curl

 

 

 

 

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

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

責任編輯:龐桂玉 來源: Linux學習
相關推薦

2024-09-29 13:25:56

2020-12-10 16:16:08

工具代碼開發

2020-12-11 06:44:16

命令行工具開發

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

2017-06-15 10:32:56

OracleDBV命令行工具

2018-04-03 13:50:27

Linux容器命令行工具

2010-02-04 15:17:48

Linux wget

2015-07-01 09:15:46

linuxQuora命令行

2018-05-04 09:15:35

PythonPlumbum命令行

2019-08-27 10:32:01

Linux操作系統Windows

2013-05-21 14:58:08

系統監視glances開源

2015-07-29 10:34:50

Linux系統命令行工具

2015-07-30 11:04:08

Linux命令行工具

2015-07-30 11:24:47

Linux 系統命令行工具

2018-11-08 14:50:14

2011-06-17 16:49:05

Cocoa蘋果
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 91久久夜色精品国产网站 | 日本不卡免费新一二三区 | 国产精品久久久久久久免费观看 | 99re66在线观看精品热 | 天堂资源最新在线 | 亚洲综合视频一区 | 国产91视频一区二区 | 欧美日韩一二三区 | 欧美黄色一区 | av中文字幕在线 | 欧美一级淫片007 | 黄色小视频入口 | 日韩中文字幕久久 | 欧美日韩一区在线播放 | 欧美一区二区三区在线观看 | 91高清在线 | 色在线免费视频 | 亚洲欧美在线观看 | 亚洲+变态+欧美+另类+精品 | 国产精品久久久久久久免费大片 | 欧美日韩精品专区 | 欧美黑人一区二区三区 | 国产精品2区 | 国产免费福利 | 国产成人福利 | 国产精品婷婷 | 久久y| 亚洲精品影院 | 91久久精品日日躁夜夜躁国产 | 一区二区三区久久久 | 天堂色综合| 91精品国产自产精品男人的天堂 | 国产精品无码专区在线观看 | 成人免费视屏 | 欧美日日 | 久久精品国产99国产精品 | 成人精品一区二区三区中文字幕 | 不卡的av在线 | 欧美日韩高清 | 高清国产午夜精品久久久久久 | 久久久久久999 |