Replacement of -d in xargs for MacOS

As we all know -d will not work in macOS.

Also, placeholder % will not work in macOS.

Look at the following command which uses xargs in Ubuntu

wp term generate category --format=ids --count=3 | xargs -d ' ' -I % wp term meta add % foo bar

The above command will give the following error if you execute in macOS

So in order to execute the above command in macOS, you could do the following:

wp term generate category --format=ids --count=3 | xargs -n1 -I {} wp term meta add {} foo bar

That’s it guys and girls!

How to fix – Fingerprint has already been taken

Sometimes we have “Fingerprint has already been taken” while adding our ssh key.

To fix that issue, we need to generate a new ssh key. But the problem is your existing ssh key is added to other resources so if you generate a new one, you have to replace it everywhere.

Instead of doing this, generate a new ssh key in a new file and add it wherever it is needed.

Run the following commands on the terminal to generate the SSH key:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Then it will ask where to generate:

Generating public/private rsa key pair. 
Enter file in which to save the key (/home/<NAME>/.ssh/id_rsa):

Give the following name for the file

/home/<NAME>/.ssh/id_rsa2

And the last step is to add it to the file by the following command:

ssh-add ~/.ssh/id_rsa2

Import large DB in MySQL using command in MAMP

Sometimes using phpmyadmin, it’s kind of impossible to import DB from the import section. So below is the command to import large DB into MySQL.

Step-1 Login to MySQL using following command

/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot

Step-2 Select DB in which you want to import DB

use DB_NAME;

Step-3 Import DB

SET autocommit=0 ; source PATH_TO_YOUR_SQL_FILE.sql ; COMMIT ;

That’s it.

Don’t forget to change path!!!