How To Get Instant Coding Answers Via Commandline In Linux

instant coding answers

Are you a programmer? I have a good news for you. Now, you can get instant coding answers via commandline using ‘howdoi’ utility in Unix-like operating systems. You don’t have to google or use any other online resources to know about some basic programming tasks. Howdoi will display the instant answers for codes and command queries right from your Terminal. This tool could be useful where you don’t have to access the web browser. It should work on any operating systems that supports python 2 and python 3, including GNU/Linux and Windows operating systems.

This brief tutorial describes how to install and use howdoi utility in Linux.

Get Instant Coding Answers Via Commandline using ‘Howdoi’

Howdoi can be easily installed using pip utility. To install pip in your Linux distribution, do the following steps.

To install PIP on Arch Linux and its derivatives, run:

sudo pacman -S python-pip

On RHEL, Fedora, CentOS:

sudo yum install epel-release
sudo yum install python-pip

Or,

sudo dnf install epel-release
sudo dnf install python-pip

On Debian, Ubuntu, Linux Mint:

sudo apt-get install python-pip

Once PIP installed, run the following command to install ‘Howdoi’.

sudo pip install howdoi

‘Howdoi’ Usage

The typical syntax of Howdoi is:

howdoi [-h] [-p POS] [-a] [-l] [-c] [-n NUM_ANSWERS] [-C] [-v] QUERY [QUERY ...]

Here,

  • -h – Displays the help section
  • -p POS – Select answer in specified position (default: 1)
  • -a – Displays the full text of the answer
  • -l  – Displays only the answer link
  • -c – Enables colorized output
  • -n NUM_ANSWERS – Number of answers to return
  • -C – Clears the cache
  • -v – Displays the current version of howdoi

Let us see some examples. For example, to know how to use print function in python or java, use following commands:

howdoi print python

Sample output:

print("Total score for %s is %s " % (name, score))
howdoi print java

Output:

System.out.print("\"Hello\"");

To know how to create an archive, just run the following command:

howdoi create tar archive

Sample output would be:

tar czf file.tar.gz file.txt

You could use this command to create a tar archive of file.txt. Similarly, you can search any commands. Here is how to know the command format to create a file or directory.

howdoi create file touch

Sample output:

touch ../my_directory/file

Similarly, you can view how to create a directory as shown below.

howdoi create directory mkdir

Sample output:

mkdir -p foo

 

To know how to format a date in bash, just run:

howdoi format date bash

Sample output:

DATE=`date +%Y-%m-%d`

Please note that this utility may not find answers to all queries, but it will help you to find answers to some basic codes and command queries.

Hope this helps.

Cheers!

Resource:

Thanks for stopping by!

How can I benefit from this blog:

Have a Good day!!

You may also like...