Знайомство з терміналом


Навігація по файловій системі


Малюнок 1

Файлова система складається з кореневого каталогу, який містить підкаталоги з назвами bin, data, users та tmp

Малюнок 2

Як і інші каталоги, домашні каталоги є підкаталогами "/Users", наприклад "/Users/imhotep", "/Users/larry" або "/Users/nelle"

Малюнок 3

Дерево каталогів під каталогом Users, де "/Users" містить каталоги "backup" та "thing"; "/Users/backup" містить "original", "pnas_final" та "pnas_sub"; "/Users/thing" містить "backup"; та "/Users/thing/backup" містить "2012-12-01", "2013-01-08" та "2013-01-27"

Малюнок 4

Дерево каталогів під каталогом Users, де "/Users" містить каталоги "backup" та "thing"; "/Users/backup" містить "original", "pnas_final" та "pnas_sub"; "/Users/thing" містить "backup"; та "/Users/thing/backup" містить "2012-12-01", "2013-01-08" та "2013-01-27"

Малюнок 5

Загальний синтаксис команди терміналу

Робота з файлами та каталогами


Малюнок 1

{alt=“Скриншот текстового редактора nano в дії з текстом”У минулому це було - публікуй чи зникни, а наразі стало - ділися та процвітай”}


Канали та фільтри


Малюнок 1

Перенаправлення та канали різних команд: "wc -l *.pdb" перенаправить виведення до терміналу. "wc -l *.pdb > lengths" will direct output to the file"lengths". "wc -l *.pdb | sort -n | head -n 1" will build a pipeline where theoutput of the "wc" command is the input to the "sort" command, the output ofthe "sort" command is the input to the "head" command and the output of the"head" command is directed to the shell

Цикли


Малюнок 1

The for loop "for filename in .dat; do echo cp $filename original-$filename;done" will successively assign the names of all ".dat" files in your currentdirectory to the variable "$filename" and then execute the command. With thefiles "basilisk.dat", "minotaur.dat" and "unicorn.dat" in the current directorythe loop will successively call the echo command three times and print threelines: "cp basislisk.dat original-basilisk.dat", then "cp minotaur.datoriginal-minotaur.dat" and finally "cp unicorn.datoriginal-unicorn.dat"

Shell Scripts


Finding Things