Tag Archives: Keyboard

CLI – sed

Screen Shot 2018-08-06 at 7.16.16 PM.png

CLI – Sometimes you have a file that you wish to scan for every instance of a phrase and replace it with another phrase. The sed or stream editor command is just what you are looking for. In the above screen shot I first display a file with the cat command, then use se to replace all appearances of the word ‘Emma’ with the word ‘Bambi’. The sed command syntax for that is:

sed  ‘s/Emma/Bambi/g’ Review_Four\ Dominions\ copy.txt

The ‘s/Emma/Bambi/g’ says to do a global search and replace of Bambi for every instance of Emma. The name of the file being operated on is ‘Review_Four\ Dominions\ copy.txt’.

The description of sed in the macOS man page is:

The sed utility reads the specified files, or the standard input if no files are specified, modifying the input as specified by a list of commands.  The input is then written to the standard output.

A single command may be specified as the first argument to sed.  Multiple commands may be specified by using the -e or -f options.  All commands are applied to the input in the order they are specified regardless of  their origin.

This can be a very powerful and useful command when processing text files. In the SysAdmin world it can be very useful for updating configuration files.

To learn a lot more about how to use sed, take a look at “‘Sed’ Command In Linux: Useful Applications Explained“. Yes, this is a Linux article, but the sed command as implemented on macOS is fundamentally the same.


See my other CLI and macOS articles


 

CLI – history

CLI – How often have you gone to the command line to run a command, one you just ran a few days earlier, but you don’t remember all of the options that gave you that perfect result? One way of being able to peer back at those commands you have entered at the command line is through the history command.

Just enter history at the command line and on a macOS system the last 512 commands entered will be shown in your terminal window from oldest to most recent. This is a command built into the default bash shell. With so many commands listed you will probably want to pipe the output of the history command into more or tail or grep to more easily find what you are looking for:

  • history | more
  • history | tail
  • history | grep <search term>

To learn a lot more about how to use apropos, take a look at “Linux history Command Tutorial for Beginners (8 Examples)“. Yes, this is a Linux article, but the history command as implemented on macOS is fundamentally the same.


See my other CLI and macOS articles


 

CLI – apropos

Screen Shot 2018-07-12 at 12.37.28 PM

You know what you want to do, but you are not sure what the command line command is that you should use. This is where the apropos command may help. While the man command gives you the details of a command, apropos searches the descriptions of all of the commands for the keyword used (in the example image above I used ‘apropos disk’ to obtain the list shown) and gives you a list of all commands that contain that keyword.

The macOS man page for apropos says:

apropos searches a set of database files containing short descriptions of system commands for keywords and displays the result on the standard output.

To learn a lot more about how to use apropos, take a look at “Linux apropos Command Tutorial for Beginners (5 Examples)“. Yes, this is a Linux article, but the top command as implemented on macOS is fundamentally the same.


See my other CLI and macOS articles


 

CLI – top

Screen Shot 2018-07-10 at 11.49.10 AM

If your system seems to be slow or there are running Apps (processes) that you want to know more about, you can enter top at the command line to see more. This command is part of almost every Unix, Linux, and macOS system.

This is similar to the Apple Utility “Activity Monitor”, though there are options you can invoke at the command line to give you more control over what you are seeing. This is a good tool to use if you are wanting to know why your Mac seems to bog down (which process is consuming CPU cycles and/or memory).

The macOS man page for top says:

The top program periodically displays a sorted list of system processes. The default sorting key is pid, but other keys can be used instead.  Various output options are available.

To learn a lot more about how to use top, take a look at “Linux top Command Tutorial for Beginners (8 Examples)” and “Tips for using the top command in Linux“. Yes, those are Linux articles, but the top command as implemented on macOS is fundamentally the same.


See my other CLI articles


Mac Keyboard Shortcuts – Screen Capture

serveimage
Tech Tip – Capturing part of my Mac screen is not something I do every day, but it is something I do every week. Apple has made this easy with three different keyboard shortcuts to capture the screen, a window or a region.

Your entire screen – To capture the screen, hit the SFT + CMD + 3. This will capture your entire desktop (even if you have multiple monitors) and save it as a .png file on your desktop.

A region of your screen – To capture a region of the screen, hit the SFT + CMD + 4. That changes the mouse pointer a cross hair. Move that crosshair to the start point, then hold the mouse button down to drag the crosshair to select the area of the screen you want to capture. When you release the mouse button the designated area will be captured to a .png file that is saved to your desktop.

A Window –  To capture an entire window, hit the SFT + CMD + 4 like you were going to capture an area. Before doing anything tap the space bar. The icon will change from a crosshair to a camera. Use that to click on any window to select it. Then click the mouse button to capture a .png file of it to your desktop.

Reference:

  1. How to take a screenshot on your Mac

See my other Mac and Keyboard Shortcut articles


 

Mac Keyboard Shortcut – Print

serveimage

A keyboard shortcut that I use, probably most everyone uses, frequently is the keyboard sequence to print:
CMD + p.

I probably don’t need to include this shortcut, but for completeness I have. In just about any App that has printable content, the CMD + p sequence will open up the Print dialog screen and let you print it.

This doesn’t save a huge amount of time, but again it is one of those quick keyboard sequences that will save you a few seconds each time you use it. Every little bit helps when you are trying to make your day more productive.


See my other Mac and Keyboard Shortcut articles


 

Keyboard Shortcuts – Shutdown System

serveimage

A keyboard shortcut that I use all the time with my MacBook is the shutdown command. The keyboard sequence in the case is:
CTL + OPT + CMD + eject.

I use this to quickly shut down my MacBook when I have finished working on it. This doesn’t save a huge amount of time, but again it is one of those quick keyboard sequences that will save you a few seconds each time you use it. Every little bit helps when you are trying to make your day more productive.


See my other Mac and Keyboard Shortcut articles


 

Keyboard Shortcuts – Quit App

serveimage

This is probably the keyboard shortcut that most users know about, but I wanted to include it in my list. I use this keyboard shortcut multiple times each day. This is the Quit App shortcut:
CMD + q.

When I finish using an App, even if I am coming back to it later in the day, I typically quit it to free up resources. I could use the Quit in the Menu Bar, but using the keyboard sequence is a little more efficient.

This will not save you a huge amount of time, but again it is one of those quick keyboard sequences that will save you a few seconds each time you use it. Every little bit helps when you are trying to make your day more productive.


See my other Mac and Keyboard Shortcut articles


 

Keyboard Shortcuts – Bookmark Current Page

serveimage

One of the keyboard shortcuts that I use multiple times each day is to bookmark the currently viewed page while in Safari:
CMD + d.

As I read the various articles in my RSS Client, Vienna, I often want to add a bookmark of the page for later reference. Using the keyboard sequence of CMD + d is faster than clicking through the menu bar.

This isn’t a huge time savings, but again it is one of those quick keyboard sequences that will save you a few seconds each time you use it. Every little bit helps when you are trying to make your day more productive.


See my other Mac and Keyboard Shortcut articles


 

Keyboard Shortcuts – Close Window or Tab

serveimage

One of the keyboard shortcuts that I use multiple times each day is Close the current window or tab. The keyboard sequence in the case is:
CMD + w.

I use this most often when in Safari with lots of tabs open to articles I have loaded from the Vienna RSS client. As I look at those I have selected to read a quick CMD + w will close the current tab and let me move on to the next I have open.

This works, as far as I can tell, on any application. If you are in a App window, CMD + w will close it too. This isn’t a huge time savings, but again it is one of those quick keyboard sequences that will save you a few seconds each time you use it. Every little bit helps when you are trying to make your day more productive.


See my other Mac and Keyboard Shortcut articles