Which

Tips on how to do various things in Linux, commands, scripts, applications

Moderators: Nanook, carl

Post Reply
User avatar
Nanook
Posting Freak
Posts: 267
Joined: Tue Jun 25, 2013 10:08 pm
Location: Shoreline
Zodiac:
Contact:

Which

Post by Nanook » Sat Oct 13, 2018 1:31 am

Suppose you are writing a script for use under cron or other environments where the $PATH may not be properly initialized. So to make sure your script will work regardless you want to include the full path of the command, but you don't know the full path. Here is how to find out. On the machine in question, bring up a terminal window and type:

which command

For example let's say you want to know where curl is:

which curl

/usr/bin/curl

Returns the path to curl.

This will only work if the command is contained in one of the directories in your $PATH variable but most often this will be the case.



Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests