Tag Archives: Keyboard

CLI – find

serveimage

CLI – We all find ourselves searching our Mac looking for a particular file or files that satisfy certain criteria. Certainly, you can use Spotlight for that, but there are also methods of searching through the command line. Those options give you much better control over your search criteria. The find command is a very flexible way of searching your machine for files.

The description of find in the macOS man page is:

NAME

find — walk a file hierarchy

SYNOPSIS

find [-H | -L | -P] [-EXdsx] [-f path] path … [expression]

find [-H | -L | -P] [-EXdsx] -f path [path …] [expression]

DESCRIPTION

The find utility recursively descends the directory tree for each path listed, evaluating an expression (composed of the “primaries” and “operands” listed below) in terms of each file in the tree.

I didn’t attempt to list the switches, primaries and operands. There are nine switches and over 60 primaries. I suggest checking out the man  page for find on your macOS machine (or on the web) to see all of your options.

Screen Shot 2019-02-28 at 5.24.37 PM

One of the ways I have used find is to look for large files. In the example above, I searched a directory for all files larger than 10 megabytes. This could easily be used to search your entire disk for large files (use +1G instead of +10M to find files larger than 1 Gagabyte in length).

Screen Shot 2019-02-28 at 5.36.43 PM

You can also search for files older than (or newer than) a specific date. I have used this feature of the find command many times. In the example above I have used cd to move to a directory that contains Science Fiction images I use for one of my Desktops. I am searching that directory looking for files that were modified (in my use case this means added) more than 10 days ago.

Those ae just two simple examples of using the find command. There are many other examples of how find can be used in the references listed at the end of this article. Because of the flixibility of the find command, it can be put to use for many tasks by the SysAdmin as well as the macOS/Linux/UNIX user.

To learn a lot more about how to use find, take a look at “Finding Files On The Command Line“. Yes, this is a Linux article, but the find command as implemented on macOS is fundamentally the same.

Check the macOS man page for cd for all of the available options.

References

  1. 25 simple examples of Linux find command
  2. 14 Practical Examples of Linux Find Command for Beginners
  3. Finding Files On The Command Line

See my other CLI and macOS articles


Advertisements

Weather at Your Terminal Command Line

screen shot 2019-01-18 at 6.17.34 pm

Web Tools – There are lots of way of getting the weather on your computer. Most of those will open in your browser with lots of content, animations, and probably advertisements. But wttr.in is different. It is text only. What is wttr.in? From their website:

wttr.in is a console-oriented weather forecast service that supports various information representation methods like terminal-oriented ANSI-sequences for console HTTP clients (curl, httpie, or wget), HTML for web browsers, or PNG for graphical viewers

screen shot 2019-01-18 at 6.11.46 pm

I used curl wttr.in from the terminal command line to get the image shown at the top of this page. This should work on any Linux or macOS system. When I enter http://wttr.in into my Safari browser I get similar output as shown in the image immediately above.

This site provides many options to choose from in their weather report. While it takes your current location as the default, other locations around the world can be specified. Queries from the US appear in USCS units, while most of the rest of the world get values in the Metric System. Optionally you can specify the units.

Reports can be returned in ANSI for the terminal, HTML for the browser, or as a .PNG image. All of the options are explained on their GitHub site.

I like this minimalist weather report and have added the URL to my Safari Favorites.

CLI – dd

serveimage

CLI – If you are wanting to copy a file from one place to another then you may want to look at the dd command. This command is particulary useful when you want to copy the file while making edits to it on the fly.

The command is also useful when copying a disk image to other media. This can be very useful in creating a bootable SD card for a Raspberry Pi. The Wikipedia page on the dd command gives a good overview of how the command can be used.

The description of dd in the macOS man page is:

The dd utility copies the standard input to the standard output.  Input data is read and written in 512-byte blocks.  If input reads are short, input from multiple reads are aggregated to form the output block.  When finished, dd displays the number of complete and partial input and output blocks and truncated input records to the standard error output.

To learn a lot more about how to use dd, take a look at “Linux dd command explained for beginners (8 examples)“. Yes, this is a Linux article, but the dd command as implemented on macOS is fundamentally the same. Check the macOS man page for dd for all of the available options.


See my other CLI and macOS articles


 

CLI – time

serveimage

CLI – Have you ever run a command from the command line and afterwards wondered how long it took to run? If so, the time command will give you that answer.

This command measures the real, user, and system time used by a command during its execution.

The description of time in the macOS man page is:

The time utility executes and times utility. After the utility finishes,
time writes the total time elapsed, the time consumed by system overhead,
and the time used to execute utility to the standard error stream. Times
are reported in seconds..

As an example I ran a three ping against the site capmac.org and timed it.

Screen Shot 2019-01-02 at 9.45.13 AM

To learn a lot more about how to use time, take a look at “Linux time Command Tutorial for Beginners (with Examples)“. Yes, this is a Linux article, but the time command as implemented on macOS is fundamentally the same. Check the macOS man page for time for all of the available options.


See my other CLI and macOS articles


 

CLI – whatis

serveimage

CLI – As mentioned before, every command line command has a descriptive man page entry that you can access. That is often a very long and detailed description of the command and all of the possible options available to it.

Sometimes you just want a quick explanation as to what a command does. This is where the whatis command is useful. It will return a one line description of the command being referenced.

The description of whatis in the macOS man page is:

whatis searches a set of database files containing short descriptions of system commands for keywords and displays the result on the standard output.  Only complete word matches are displayed.

To learn a lot more about how to use whatis, take a look at “Linux whatis Command Tutorial for Beginners (5 Examples)“. Yes, this is a Linux article, but the whatis command as implemented on macOS is fundamentally the same. Check the macOS man page for whatis for all of the available options.


See my other CLI and macOS articles


 

Mac Keyboard Shortcuts – Scrolling down with the Spacebar

serveimage
Tech Tip – I was unaware that this shortcut existed until I read “There’s a keyboard shortcut that will transform how you browse the web hiding in plain sight” today. Needless to say, this is a Keyboard Shortcut I will use dozens of time each day from now on!

I just tested this on my Mac with both Safari and Google Chrome. It works as advertised on both, scrolling down the viewed page one screen at a time each time the spacebar is pressed.

This doesn’t sound like much, but if you are reading through multiple web pages each day using this keyboard shortcut can save you time. As I have said before, each time you shave seconds from your daily work process, you make yourself that much more productive.


See my other Mac and Keyboard Shortcut articles


 

Mac Keyboard Shortcuts – Reply in Mail

serveimage
Tech Tip – We almost all use Apple Mail as our email client on the Mac. One keyboard shortcut that will save you time is for replying to your email messages.

This is one of the simpler shortcuts. While reading your email, you can reply to one by simply holding down on the CMD key and pressing “r”. This will then open the reply window and allow you to type in your response. To reply to all simply use SFT + CMD + r instead.

This doesn’t sound like much, but if you are replying to multiple mail messages each day, you will end up saving many seconds per message. As I have said before, each time you shave seconds from your daily work process, you make yourself that much more productive.


See my other Mac and Keyboard Shortcut articles


 

CLI – tcpdump

serveimage

CLI – If you are having network connectivity issues tcpdump is a utility that you may want to try. It is also handy when you want to examine unusual network traffic.

This command allows you to capture and analyze network traffic. Using this command is probably going to require you to put on your ‘propeller hat’ and drop further down ‘into the weeds’ of tech than you are typically used to. It is good to know that the ability is there if you need it.

The description of tcpdump in the macOS man page is:

Tcpdump prints out a description of the contents of packets on a network interface that match the boolean expression; the description is preceded by a time stamp, printed, by default, as hours, minutes,  seconds, and fractions of a second since midnight.  It can also be run with the -w flag, which causes it to save the packet data to a file for later analysis, and/or with the -r flag, which causes it to read from a saved packet file rather than to read packets from a network interface. It can also be run with the -V flag, which causes it to read a list of saved packet files. In all cases, only packets that match expression will be processed by tcpdump.

To learn a lot more about how to use tcpdump, take a look at “An introduction to using tcpdump at the Linux command line“. Yes, this is a Linux article, but the tcpdump command as implemented on macOS is fundamentally the same. Check the macOS man page for tcpdump for all of the available options.


See my other CLI and macOS articles


Mac Keyboard Shortcuts – Creating a Link

serveimage
Tech Tip – I find myself typing in URLs every day. This might be in Notes, Pages, Numbers, Keynote, TextEdit, or Mail. But I don’t just want the URL to be there, I want it to be an active link. To accomplish this I can use the CMD + k key combination.

Screen Shot 2018-09-02 at 12.42.01 PM

To make any text in one of the Apps mentioned above a link, just highlight the text in the document, then type CMD + k on the keyboard. This will open up a dialog box (as seen above) where you can enter the desired link. Type or paste in the full URL, then tap OK or hit return and the link has been created.

I use this on an almost daily basis. It is a fast way to create a link in your documents or Notes. The dialog box varies a little between applications giving more options in some (like Keynote) but the key sequence in all allows you to create a link.

This works for other applications too. For instance, I tried CMD + k while typing this article into the WordPress website editor and it works there too. Try this with your favorite Apps to see just where it works.


See my other Mac and Keyboard Shortcut articles


 

CLI – bzip2

CLI – If you have a file you want to compress, you have options as to how you will do it. The bzip2 command is one of the options that is open to you on a macOS system. Likewise, if you come across a previously compressed file with the .bz2 extension, you will want to use bzip2 to decompress it.

The description of bzip2 in the macOS man page is:

bzip2  compresses  files  using  the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. Compression is generally considerably better than   that achieved by more conventional LZ77/LZ78-based compressors, and approaches the performance of the PPM family of statistical compressors.

To learn a lot more about how to use bzip2, take a look at “Linux bzip2 Command Tutorial for Beginners (6 Examples)“. Yes, this is a Linux article, but the bzip2 command as implemented on macOS is fundamentally the same. Check the macOS man page for bzip2 for all of the available options.


See my other CLI and macOS articles