[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
question regarding linux command line
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /wsr/ - Worksafe Requests

Thread replies: 6
Thread images: 1
File: zCd3pqC.jpg (164 KB, 724x500) Image search: [Google]
zCd3pqC.jpg
164 KB, 724x500
hey guys, can someone tell me what does ./ do in linux command line

google gives me nothing and i couldnt find it anywhere else

pic unrelated
>>
./ does nothing.

./something tries to execute something in the current working directory. If this something doesn't exist or is not set executable, then nothing happens.
>>
>>117703
hm thanks, but what happens if i put it like this
./something a b c
how do i include a b c in my code, is it stdin?
i dont use linux and this is asked from my prof
sorry for my ignorence
>>
>>117704
Yeah. In that case, a, b and c are parameters.
>>
>>117702
It references the current directory, e.g.
>ls ./
will list the contents of the current directory. This is the same as
>ls .
or just
>ls

Every directory always has two special links in it, '.' and '..'. The single dot references itself, while the two dots reference its parent directory (the only exception being the root directory, where .. will also point to itself).

>>117704
>how do i include a b c in my code, is it stdin?
No, they're command line arguments. The way to access them will vary depending on which language you're using. For example, in python, they'll be available in sys.argv. See
https://en.wikipedia.org/wiki/Command-line_interface#Arguments
https://en.wikipedia.org/wiki/Entry_point#Programming_languages

Stdin will either contain input read from the keyboard, or piped from another program, for example:
>echo a b c | ./something
Here, "a b c" would be available through stdin.
>>
>>117702
./ is a way for the command line to differentiate between asking it to run a command residing at some directory in your $PATH variable (type "echo $PATH" to see what they are) and asking it to run a specific command somewhere else.

If you specify a path then it will ignore your $PATH variable and just run the program you've specified. If you don't specify a path then it will only search for the program in side the directories defined in your $PATH.


An example might be helpful:
Say you have a program called FOO inside your current directory. Typing "FOO" will result in "command not found" because it doesn't exist in your $PATH directories.
So according to what I said above, you know that in order to specify where the program is you have to supply a path to it. It could be something like
>/home/user/programs/FOO
That will run your program. However, there are shortcuts that make typing paths easier, for example "~" refers to your home directory (/home/user) a ".." refers to the previous directory, and a "." refers to the current directory.
So typing:
>./FOO
would be equivalent to /home/user/programs/FOO in the example above, and that tells the command line to not search $PATH and instead just run FOO from the current directory.
Thread replies: 6
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.