Command-line tool

  • Evergreen
  • u.
  • c.

Useful built-in (macOS) command-line tools with examples.

curl

Client for URLs. Basic usage is for transfering data to and from servers using URLs.

Example

Request the contents of example.com.

Terminal window
$ curl example.com
<!doctype html><html lang="en"><head><title>Example Domain</title>...

dig

Domain information groper. Basic usage is for querying DNS records for a domain.

Example

Query A records for the domain example.com.

Terminal window
$ dig example.com A
;; ANSWER SECTION:
example.com. 133 IN A 104.20.23.154
example.com. 133 IN A 172.66.147.243

grep

Global regular expression print. Basic usage is for searching for text in a file using a regular expression, and print any lines that contain a match.

Example

Search, ignoring case (-i), for any line that start with “hello” in the file greeting.txt.

Terminal window
$ grep -i '^hello' greeting.txt
Hello, world!

sed

Stream editor. Basic usage is for transforming a text stream, such as from a text file, and apply a command.

Example

Substitute (s) the word “world” for the word “you” in the text stream read from file greeting.txt.

Terminal window
$ sed 's/world/you/' greeting.txt
Hello, you!

Backlinks