Often you will grep for certain strings in a text file, but need to find which line it’s on within that file. On a standard grep output, you will see the output, but have no idea which line the string has been found on. grep has an option, -n, which resolves that. As an example, …
Tag Archives: os x
Add Line Numbers to “cat” Output
cat can be used to print the contents of a file in a Terminal, and it’s often useful to number each line of the output (including empty lines). Adding line numbers is as simple as adding the -n switch to the command: cat -n filename.txt Example Output, with -n switch: $ cat -n filename.txt 1 Line …
Using grep and Ignoring Case (Case Insensitive grep)
grep is a great way to find phrases, words, and characters in text. One of the biggest stumbling blocks is case – is the word “Hello”, “hello”, “HELLO”, or even “HeLLo”? All of these are different, and a “grep “Hello”” would only find lines containing the first “Hello” example. You can, however, exclude case from …
Continue reading “Using grep and Ignoring Case (Case Insensitive grep)”
Using dig to Query a Specific DNS Server (Name Server) Directly (Linux, BSD, OSX)
There may be occasions when you wish to query a DNS server directly. I often do it before changing DNS servers for a domain; I’ll setup the new records on the new DNS servers, and then query them directly to ensure they are returning the correct records. I recommend that anyone running DNS services for …
Continue reading “Using dig to Query a Specific DNS Server (Name Server) Directly (Linux, BSD, OSX)”
Checking the Uptime of your OS X Machine
Uptime, uptime, uptime. Everyone loves massive uptime, right? The “Who’s PC has been on the longest without a reboot?” sort of challenges. Well, finding out the uptime on an OS X machine is quite easy! If you open a Terminal (by using Spotlight, then searching for Terminal or open Applications/Utilities and double click Terminal) and …
How to Stop .DS_Store From Being Created on Network Drives (OS X)
.DS_Store files can make even the tidiest network shares look horrible to none-OS X users. Whenever an OS X machine accesses a network share, it creates a .DS_Store file for it’s own use (on SMB/CIFS, AFP, NFS, and WebDAV servers). These files are invisible to the OS X user, but will show up to anyone …
Continue reading “How to Stop .DS_Store From Being Created on Network Drives (OS X)”
Using SCP Aliases to Upload Files Quicker (OS X, BASH)
If like me, you have a particular path on a server you always upload files to, via SCP, then you’ll probably want a better way than typing the full path into the scp command everytime you upload a file! This command has been tested on OS X, but there’s no reason it wouldn’t work on …
Continue reading “Using SCP Aliases to Upload Files Quicker (OS X, BASH)”
SSH Client: Saving Server Configuration (Alias, Port, Username)
There may be occasions where you want to connect to a host with a long host name, for example ssh servername.example.com – now it’s not massive, but it’s not as quick as ssh servername If you’ve been following droptips.com, you’ll have noticed my other post about setting the port number in the SSH config file …
Continue reading “SSH Client: Saving Server Configuration (Alias, Port, Username)”
SSH Client: Automatically Connect to a Servers’ Non-Standard Port
If you run an SSH server, or many SSH servers, then you may have set the SSH daemon to run on a non-standard port. SSH normally listens on port 22, but with the large amount of script/bot attacks now on this port, attempting random logins, changing it to something different is a quick way to …
Continue reading “SSH Client: Automatically Connect to a Servers’ Non-Standard Port”
Access Your OS X Clipboard from the Command Line
There may be times when you need to access whatever is on your clipboard in a Terminal; maybe a particularly long URL for example. And, there may be times when you want to put things on to the clipboard from a Terminal. Reading the Clipboard As it’s going to be text on the clipboard (even …
Continue reading “Access Your OS X Clipboard from the Command Line”