This is an old revision of the document!
>
, <
, &
, |
, ||
, &&
, ;
, "
, ', \
, $
, one liner, variabile, variabile de mediu, escaping, expandare, globbingDaca rulati in terminal comanda:
echo $PATH
Veti vedea o lista de directoare de genul:
/home/student/.local/share/umake/bin:/home/student/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
Daca puneti un executabil in oricare din aceste directoare, nu mai este nevoie sa setati calea catre executabil si puteti sa il rulati direct ca o comanda, folosind numele executabilului.
student@myPc:~/USO/test$ ls endian.c endian.o hello hello.c Makefile socket.c struct.c struct.o student@myPc:~/USO/test$ ls *.c endian.c hello.c socket.c struct.c student@myPc:~/USO/test$ ls end?an.c endian.c student@myPc:~/USO/test$ ls [a-s]*.c endian.c hello.c socket.c struct.c student@myPc:~/USO/test$ ls *.{c,o} endian.c endian.o hello.c socket.c struct.c struct.o
Mai sus avem cateva exemple de rulare a comenzii ls impreuna cu expresii regulate.
Ce reprezintă fiecare operator?
student@myPc:~/USO/test$ ls -l total 0 -rw-r--r-- 1 student student 0 nov 8 17:41 'ana are mere.txt' -rw-r--r-- 1 student student 0 nov 8 17:18 endian.c -rw-r--r-- 1 student student 0 nov 8 17:18 endian.o -rw-r--r-- 1 student student 0 nov 8 17:00 hello -rw-r--r-- 1 student student 0 nov 8 17:00 hello.c -rw-r--r-- 1 student student 0 nov 8 17:00 Makefile -rw-r--r-- 1 student student 0 nov 8 17:01 socket.c -rw-r--r-- 1 student student 0 nov 8 17:00 struct.c -rw-r--r-- 1 student student 0 nov 8 17:01 struct.o student@myPc:~/USO/test$ ls ana are mere.txt ls: cannot access 'ana': No such file or directory ls: cannot access 'are': No such file or directory ls: cannot access 'mere.txt': No such file or directory student@myPc:~/USO/test$ la "ana are mere.txt" 'ana are mere.txt' student@myPc:~/USO/test$ ls 'ana are mere.txt' 'ana are mere.txt' student@myPc:~/USO/test$ ls ana\ are\ mere.txt 'ana are mere.txt'
student@myPc:~/USO/test$ echo "Hello World" Hello World student@myPc:~/USO/test$ echo Hello World Hello World student@myPc:~/USO/test$ echo "Hello \"World\"" Hello "World" student@myPc:~/USO/test$ echo "Hello "World"" Hello World
student@myPc:~/USO/test$ echo \" " student@myPc:~/USO/test$ echo "" student@myPc:~/USO/test$ echo \"\" ""
student@myPc:~/USO/test/files$ touch $(seq -f "file-%02g.txt" 1 20) student@myPc:~/USO/test/files$ touch file.txt student@myPc:~/USO/test/files$ ls file-01.txt file-04.txt file-07.txt file-10.txt file-13.txt file-16.txt file-19.txt file-02.txt file-05.txt file-08.txt file-11.txt file-14.txt file-17.txt file-20.txt file-03.txt file-06.txt file-09.txt file-12.txt file-15.txt file-18.txt file.txt student@myPc:~/USO/test/files$ rm -rf $(seq -f "file-%02g.txt" 1 20) student@myPc:~/USO/test/files$ ls file.txt
student@myPc:~/USO/test/files$ a=6 student@myPc:~/USO/test/files$ echo a a student@myPc:~/USO/test/files$ echo $a 6 student@myPc:~/USO/test/files$ echo $((a)) 6 student@myPc:~/USO/test/files$ a++ Command 'a++' not found, did you mean: command 'a+' from deb aplus-fsf command 'g++' from deb g++ command 'c++' from deb g++ command 'c++' from deb clang command 'c++' from deb libc++-helpers command 'c++' from deb pentium-builder command 'ac++' from deb aspectc++ command 'ag++' from deb aspectc++ Try: sudo apt install <deb name> student@myPc:~/USO/test/files$ ((a++)) student@myPc:~/USO/test/files$ echo $a 7 student@myPc:~/USO/test/files$ b=$((a-4)) student@myPc:~/USO/test/files$ echo $b 3