Internal commands are buil-in commands.
If you don't know the type of a command, you can use "type" command:
..$ type cd
cd is a shell builtin
..$ type pwd
pwd is a shell builtin
..$ type bash
bash is /bin/bash
There is a trick about "type" command:
..$ type -a pwd
pwd is a shell builtin
pwd is /bin/pwd
"-a" option shows us is the command duplicated by external command or not.
let's understand it with "time" command:
..$ time pwd
/home/user
real 0m0.000s
user 0m0.000s
sys 0m0.000s
..$/usr/bin/time pwd
/home/user
0.00user 0.00system 0:00.04elapsed 0%CPU
(0avgtext+0avgdata 2240maxresident)k
64inputs+0outputs (1major+83minor)pagefaults 0swaps
So what happened up there:
When we typed "time pwd" we used the internal(built-in) time command
Then we typed "/usr/bin/time pwd" that was the external time command
I hope this is a helpful explanation about difference between internal and external commands.
command etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
command etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
5 Ekim 2016 Çarşamba
3 Eylül 2016 Cumartesi
test command
Varsayalım ki bulunduğunuz directory içinde file1 ve file2 olmak üzere 2 file var.
test command ile ne yapabileceğimize bakalım:
..$ test -f file1
..$
Gördüğünüz üzere herhangi bir çıktı almadık.
..$ test -f file1 && echo "true"
true
test -f komutu bize file check etmemiz için gerekli.
Ardından gelen file1, check etmek istediğimiz file.
&& : if it's true anlamına gelir.
echo "true" : true çıktısı verir.
..$ test -w file1 && echo "true"
true
Yukarıda yaptığımız şey ise file 1 in writable olup olmadığını gösterdi. -w flag i -writable anlamına gelmektedir.
Şimdi biraz daha farklı bir şey deneyelim:
..$ test 1 -gt 2 && echo "true"
..$
Eğer 1 is greater than 2 ekrana true yaz. görüldüğü üzere herhangi bir çıktı almadık.
-gt flag i greater than anlamına gelmektedir.
..$ test 2 -gt 1 && echo "true"
true
İf it's false
double pipe : | |
..$ test 1 -gt 2 && echo "true" | | echo "false"
false
if it's equal
..$ [ 5 -eq 5 ]; echo $?
0
..$ [ 5 -eq 6 ]; echo$?
1
Doğruluk durumunda 0
Yanlışlık durumunda 1 çıktısı aldık.
..$ [ 5 = 5 ]; echo $?
0
..$ [ 5 = 6 ]; echo $?
1
test command ile yaparsak:
..$ test 5 -eq 6 && echo "true" | | echo "false"
false
kaynak: linuxacademy.com
test command ile ne yapabileceğimize bakalım:
..$ test -f file1
..$
Gördüğünüz üzere herhangi bir çıktı almadık.
..$ test -f file1 && echo "true"
true
test -f komutu bize file check etmemiz için gerekli.
Ardından gelen file1, check etmek istediğimiz file.
&& : if it's true anlamına gelir.
echo "true" : true çıktısı verir.
..$ test -w file1 && echo "true"
true
Yukarıda yaptığımız şey ise file 1 in writable olup olmadığını gösterdi. -w flag i -writable anlamına gelmektedir.
Şimdi biraz daha farklı bir şey deneyelim:
..$ test 1 -gt 2 && echo "true"
..$
Eğer 1 is greater than 2 ekrana true yaz. görüldüğü üzere herhangi bir çıktı almadık.
-gt flag i greater than anlamına gelmektedir.
..$ test 2 -gt 1 && echo "true"
true
İf it's false
double pipe : | |
..$ test 1 -gt 2 && echo "true" | | echo "false"
false
if it's equal
..$ [ 5 -eq 5 ]; echo $?
0
..$ [ 5 -eq 6 ]; echo$?
1
Doğruluk durumunda 0
Yanlışlık durumunda 1 çıktısı aldık.
..$ [ 5 = 5 ]; echo $?
0
..$ [ 5 = 6 ]; echo $?
1
test command ile yaparsak:
..$ test 5 -eq 6 && echo "true" | | echo "false"
false
kaynak: linuxacademy.com
Kaydol:
Yorumlar (Atom)