Category Archives: Mac

Linux : Search and replace across multiple files

To search and replace across multiple text file on a Linux/Unix system, use the following command :

find . -name “*.extension” -print | xargs sed -i ‘s/search_for_text/replace_with_text/g’

So, as example, let’s assume you want to replace an IP address in multiple Bind zone file (using the extension .hosts) and replace IP address 10.10.1.1 for 192.168.1.1 :

find . -name “*.hosts” -print | xargs sed -i ‘s/10.10.1.1/192.168.1.1/g’

Mac : How to convert Windows text file to unix

Windows text editors add a tailing character ( ^M ) for line break. To get a real Unix flat file without theses characters, simply run the following command in terminal :

tr ‘\r’ ‘\n’ < Windows_Text_File.txt > Unix_Text_File.txt

Mac : How to Page up and Page down in terminal?

Using the full size desktop Apple keyboard, simply hold down SHIFT key + Page up or Page down.

With a MacBook Pro, there is no such keys (Page up/Page down)… Just hold down function key ( fn ) + SHIFT + ARROW UP and/or DOWN.

RoundCube : Server Error UID COPY Error in IMAP command received by server

Since RoundCube version 0.6, you may expect the following error when trying to delete a message :

Server Error : UID COPY : Error in IMAP command received by server.

You probably using Courier-IMAP daemon.  As commented in “main.inc.php” configuration file for default storage folders, you need to modify the folder name according to the fully qualified name.  Just add ” INBOX. ” in front of each folder name and it should be working.

So, as exemple, the default value :

$rcmail_config['trash_mbox'] = ‘Trash’;

Should look like this :

$rcmail_config['trash_mbox'] = ‘INBOX.Drafts’;

Vim : how do I search and replace text

Do the following to find and replace text string in a whole file using the Vi text editor :

1. Enter in command mode by typing ” :

2. Your command should look like this :

%s/search_for_text/replace_with_this_text/g

Mac : Add a static route in OSX

To add a static route in Mac OSX, do the following as root in the terminal :

route -n add “network/prefix” “gateway”

Example : route -n add 10.0.0.0/8 10.16.1.1

To print the routine table, use the following command :

netstat -nr

Mac : Flush local dns cache

MacOSX run a local named caching server.  In some reason you may need to refresh it manually to get a resent updated DNS record.

Under Mac OSX 10.4 and below, use the following command using the terminal :

lookupd -flushcache

Under Mac OSX 10.5 and above, use :

dscacheutil -flushcache

MacOSX Server : How to disable named

To permanently disable local dns server on a MacOSX Server simply run the following command as root :

sudo /bin/launchctl unload -w /System/Library/LaunchDaemons/org.isc.named.plist

You will be prompted to enter the administrative password next and you’re done!

Mac : Change the hostname

Changing the hostname can be done through the GUI or console.

Go to System Preferences > Sharing. On top of the window, click on Edit to change the computer name.

The command line for the console is the following :

sudo scutil –set HostName “your_hostname”

Outlook Mac : Where temporary files are saved ?

Outlook Mac store temporary files such as e-mail signatures, opened attachment and other e-mail content in the following location :

~/Library/Caches/TemporaryItems/Outlook Temp/