Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ПР4.doc
Скачиваний:
2
Добавлен:
06.05.2019
Размер:
75.78 Кб
Скачать

Упражнение 1

- загрузил OC QNX и вошел в систему. Создал текстовый файл.

# tee File1.txt

1 2 3 4 5 6 7 8 9 0

1 2 3 4 5 6 7 8 9 0

a b c d f no

a b c d f no

A B C D F NO

A B C D F NO

bubble

bubble

staff 55

staff 55

staff bubble

staff bubble

#

Упражнение 2

- продемонстрировал возможности изученных команд по обработке текстовых файлов.

# grep "^[a-zA-Z]" File1.txt

a b c d f no

A B C D F NO

bubble

staff 55

staff bubble#

# grep -v bubble File1.txt

1 2 3 4 5 6 7 8 9 0

a b c d f no

A B C D F NO

staff 55

# ls -1 | grep staff

staff 2

staff a b c

# grep no *

File1.txt:a b c d f no

# ls -1 /etc | grep '^1'

# ls -1 /usr/lib | grep '^d' | more

# ls -1 /usr/doc | grep '^d' | grep 'lib' | more

ls: No such file or directory (/usr/doc)

# diff File1.txt File2.txt

1c1

< 1 2 3 4 5 6 7 8 9 0

---

> 1 2 34 56 78 9 0

3,6c3,6

< A B C D F NO

< bubble

< staff 55

< staff bubble

\ No newline at end of file

---

> ABCDFNO

> bubble33

> staff 552

> staff bubble 3

\ No newline at end of file

# diff -w File1.txt File2.txt

4,6c4,6

< bubble

< staff 55

< staff bubble

\ No newline at end of file

---

> bubble33

> staff 552

> staff bubble 3

\ No newline at end of file

# wc File1.txt

5 27 74 File1.txt

# wc -cw File1.txt*

74 27 File1.txt

# ls -1

.

..

.lastlogin

.ph

.profile

Strok1.txt

Strok2.txt

Strok3.txt

Strok4.txt

Strok5.txt

# ls -1 | sed '4a\

> newstrok'

.

..

.lastlogin

.ph

newstrok

.profile

Strok1.txt

Strok2.txt

Strok3.txt

Strok4.txt

Strok5.txt

# ls -1 | sed '/Strok2.txt/ c\

> zamena'

.

..

.lastlogin

.ph

.profile

Strok1.txt

zamena

Strok3.txt

Strok4.txt

Strok5.txt

# ls -1 | sed '5,7d'

.

..

.lastlogin

.ph

Strok3.txt

Strok4.txt

Strok5.txt

# ls -1 | sed '4i\

> newstrok'

.

..

.lastlogin

newstrok

.ph

.profile

Strok1.txt

Strok2.txt

Strok3.txt

Strok4.txt

Strok5.txt

# ls -1 | sed 's/t/T/'

.

..

.lasTlogin

.ph

.profile

STrok1.txt

STrok2.txt

STrok3.txt

STrok4.txt

STrok5.txt

# ls -1 | sed 'y/rok/ROK/'

.

..

.lastlOgin

.ph

.pROfile

StROK1.txt

StROK2.txt

StROK3.txt

StROK4.txt

StROK5.txt

# ls -1 | sed =

1

.

2

..

3

.lastlogin

4

.ph

5

.profile

6

Strok1.txt

7

Strok2.txt

8

Strok3.txt

9

Strok4.txt

10

Strok5.txt

#