Сценарии практического занятия на тему: Работа с файлами в UNIX

«Вопросы»

  1. pwd
  2. cd /
  3. ls
  4. ls -F
  5. ls ~
  6. cd
  7. mkdir test
  8. ls
  9. mkdir test/subtest
  10. ls -R

«Вопросы»

  1. touch first.txt
  2. echo
  3. echo "Hello, world" >> first.txt
  4. cat first.txt
  5. ls
  6. alias ls='ls -F -l'
  7. ls
  8. cp first.txt copy1.txt
  9. mv first.txt orig.txt
  10. mv first.txt orig.txt
  11. ln orig.txt copy2.txt
  12. ln -s orig.txt orig.lnk

«Вопросы»

  1. find
  2. find -name "o*"
  3. find /etc -name "o*"
  4. find /etc -name "o*" 2>/dev/null
  5. find /etc -name "o*" -a -type d 2>/dev/null
  6. mkdir logs
  7. find /var -name "*log" -a -type f -exec cp {} test/logs/ 2>/dev/null

«Вопросы»

  1. cd
  2. tar -czf test.tar.gz test
  3. mkdir test2
  4. cd test2
  5. tar -xzf ../test.tar.gz
  6. ls -l -a -F

«Вопросы»

  1. cd ~/test
  2. echo "One line"
  3. echo "One line" > second.txt
  4. echo "A line" >> second.txt
  5. cat second.txt
  6. cat > multiline.txt
  7. cat multiline.txt
  8. cat orig.txt second.txt multiline.txt > big.txt
  9. cat big.txt

«Вопросы»

  1. cat /etc/passwd
  2. cat /etc/passwd | cut -f1 -d:
  3. cat /etc/passwd | cut -f1 -d: | sort
  4. cat /etc/passwd | cut -f7 -d:
  5. cat /etc/passwd | cut -f7 -d: | uniq
  6. sort
  7. cat /etc/passwd | cut -f7 -d: | sort | uniq
  8. cat /etc/passwd | cut -f1 -d: > users
  9. cat /etc/passwd | cut -f7 -d: > shells
  10. paste users shells

«Вопросы»

  1. wc -l /etc/passwd
  2. cat users | wc -w
  3. head logs/Xorg.0.log
  4. tail logs/Xorg.0.log

«Вопросы»

  1. less test/logs/Xorg.0.log
  2. grep "^(WW)" test/logs/Xorg.0.log
  3. grep "[a-zA-z0-9]\+@[a-zA-z0-9\.]\+\.[a-z]\{2,4\}" /etc/* 2>/dev/null
  4. grep
  5. grep -h "[a-zA-z0-9]\+@[a-zA-z0-9\.]\+\.[a-z]\{2,4\}" /etc/* 2>/dev/null
  6. grep -ho "[a-zA-Z0-9]\+@[a-zA-Z0-9\.]\+\.[a-z]\{2,4\}" /etc/* 2>/dev/null
  7. find /etc -type f 2>/dev/null
  8. find /etc -type f -exec grep "nameserver" {} \; 2>/dev/null
  9. find /etc -type f -exec grep -Hn "nameserver" {} \; 2>/dev/null