2011年05月06日 情報科学類 コンピュータリテラシ 筑波大学 システム情報工学研究科 コンピュータサイエンス専攻, 電子・情報工学系 新城 靖 <yas@is.tsukuba.ac.jp>
このページは、次の URL にあります。
http://www.coins.tsukuba.ac.jp/~yas/coins/literacy-2011/2011-05-06
あるいは、次のページから手繰っていくこともできます。
http://www.coins.tsukuba.ac.jp/~yas/
http://www.cs.tsukuba.ac.jp/~yas/
$ ls -l > file1
シェルは、「記号<」 があると、標準入力をキーボードから指定され
たファイルに切り替え、指定されたプログラムを実行する。
$ cat < file1
シェルは、「記号|
」があると、次の動作を行う (パイプ(pipe)機能)。
|
」の左のプログラム(プロセス)の標準出力を、右のプログ
ラム(プロセス)の標準入力に(ファイルを介することなく)接続する。
$ ls -l | head -4
total 222
drwx------ 10 yas prof 4096 4 26 18:51 Desktop
drwx------ 4 yas prof 4096 4 2 14:14 Documents
drwxr-xr-x@ 2 yas prof 4096 4 26 12:51 Downloads
$
ファイルを介しても類似の操作は可能だが、後で不要なファイルを消さなけれ
ばならない。
$ ls -l > file
$ head -4 < file
total 222
drwx------ 10 yas prof 4096 4 26 18:51 Desktop
drwx------ 4 yas prof 4096 4 2 14:14 Documents
drwxr-xr-x@ 2 yas prof 4096 4 26 12:51 Downloads
$ rm file
$
パイプは、3つ以上のプログラム(プロセス)を結びつけることもできる。
$ ls Document > file
ls: Document: No such file or directory
$ cat file
$
「Document
」 は、「Documents
」の打ち間違い(sがない)である。
ls コマンドは、エラー・メッセージを標準出力ではなく標準エラー出力に書き
出す。
「2>file
」をつかうと、標準エラー出力をファイルに保存
することもできる。
$ ls Document > file 2>file2
$ cat file
$ cat file2
ls: Document: No such file or directory
$
「2>&1
」をつかうと、標準エラー出力(2)を、標準出力
(1)に混ぜて(&
)、ファイルに保存することもできる。
$ ls Document > file 2>&1
$ cat file
ls: Document: No such file or directory
$
「2>&1
」は、順番が大事。ファイルに混ぜて保存する場合
は、「>file
」の後にやること。先にやると、その時点で
の標準出力(画面)が指定されてしまう。
$ ls Document 2>&1 > file
ls: Document: No such file or directory
$ cat file
$
2>&1
を使うと、エラー・メッセージも含めてパイプに出力
することもできる。この場合は、パイプ|
より左に書く。
$ ls Document 2>&1 | head -4
ls: Document: No such file or directory
$
補完(completion)では、人間が目で確認するが、置き換えでは人間が確認する ことはない(見つからなければエラーになる)。
例:/usr/bin
にある at
で始まるファイルをすべて
ls
コマンドに引き渡したい。1つひとつ打つと疲れる。
$ ls /usr/bin/at /usr/bin/atos /usr/bin/atq /usr/bin/atrm /usr/bin/atsutil
/usr/bin/at /usr/bin/atq /usr/bin/atsutil
/usr/bin/atos /usr/bin/atrm
$
次のように、「*
」を使うと楽に打てる。
$ ls /usr/bin/at*
/usr/bin/at /usr/bin/atq /usr/bin/atsutil
/usr/bin/atos /usr/bin/atrm
$
この例では、シェルが「/usr/bin/at*
」を5つのファイル名に置き換え
ている。ls
が行っているのではない。ls
以外のどんなプログラ
ムでも有効である。
$ echo /usr/bin/at*
/usr/bin/at /usr/bin/atos /usr/bin/atq /usr/bin/atrm /usr/bin/atsutil
$ file /usr/bin/at*
/usr/bin/at: setuid Mach-O fat file with 3 architectures
/usr/bin/atos: Mach-O fat file with 2 architectures
/usr/bin/atq: setuid Mach-O fat file with 3 architectures
/usr/bin/atrm: setuid Mach-O fat file with 3 architectures
/usr/bin/atsutil: Mach-O fat file with 3 architectures
$
パタン | 意味 |
* | 任意の文字列(空でもよい)(.で始まるものを除く) |
? | 任意の1文字 |
[str] | strのなかの1文字。たとえば [aA] は、a か A とマッチする。「-」があると、ASCIIでその間の文字を意味する。たとえば [0-9](数字)や[a-zA-Z](アルファベット)がよく使われる。 |
{str1,str2,...} | 「,」で区切られたパタン str1, str2, ... を順にファイル名置換した結果を並べたもの |
~username | ユーザusernameのホーム・ディレクトリの絶対パス。 |
~/ | 自分自身のホーム・ディレクトリ |
~ | 自分自身のホーム・ディレクトリ |
よく使われる形式
*
」と「*.*
」は違う。Windowsで「*.*
」と書く
所、Unixでは、「*
」で十分なことが多い。
$ ls -ld /Applications/QuickTime Player.app/
ls: /Applications/QuickTime: No such file or directory
ls: Player.app/: No such file or directory
$
「?」や「*」で置き換え可能な場合が多い。
$ ls -ld /Applications/QuickTime?Player.app/
drwxr-xr-x 3 root wheel 102 11 14 23:31 /Applications/QuickTime Player.app/
$ ls -ld /Applications/QuickTime*Player.app/
drwxr-xr-x 3 root wheel 102 11 14 23:31 /Applications/QuickTime Player.app/
$
バックスラッシュ「\ 」を使うこともできる。
$ ls -ld /Applications/QuickTime\ Player.app/
drwxr-xr-x 3 root wheel 102 11 14 23:31 /Applications/QuickTime Player.app/
$
$ history
1 saykotoeri2
2 saykotoeri2
3 fg
4 dup
...
500 history
$
^P
/ ^N
で、ヒストリを
さかのぼれる。
その他に、次のような方法もある。bash では、ほとんど使われない。編集機能 がないシェルでは有効であった。
$ ls file.txt
file.txt
ここで -l を付けわすれたのに気がつく
$ ls -l !$
ls -l file.txt
-rw-r--r-- 1 yas prof 9 4 29 21:23 file.txt
$
木構造(tree structure)というのは、コンピュータ・サイエン ス(情報科学類で学ぶ学問)でよく使われる用語。 階層構造(hierarchical structure)ともいう。
木構造の例を、大学の組織を使って説明する(図?)。
筑波大学
コンピュータの中で、文字列(文字の並び)で木構造上の位置を表現する時に は、節が分かりやすくために、はっきりと区切りを入れて表現することがよく 行われる。
区切り文字としては、「.」(点)、「/」(スラッシュ)、「\」(バック スラッシュ)、「¥」(円記号)などがよく使われる。単語を並べる時に、木 の根に近いほうから書く流儀と遠い方から書く流儀がある。
コンピュータでは、次のような場所で木構造が使われている。
コンピュータ以外では、次のような場所で木構造が使われている。
http://www.softlab.cs.tsukuba.ac.jp/~yas/gen/it-2009-09-24/
ルート・ディレクトリの名前は、「/
」 (スラッシュ 1 文字)。
ルートディレクトリから出発する方法で表記するパス名を、 絶対パス名(absolute path name)
絶対パス名は、ルートディレクトリを表す「/」の後に、 たどった枝の名前を並べ、間に区切りとして「/」をはさむ。
例:「/usr/bin/wc
」
usr
」という枝に進む
bin
」という枝に進む
wc
」という枝に進む
カレント・ワーキング・ディレクトリを表示するには、pwd (print working directory) コマンドを使う。
$ pwd
/USA/California
$
表示されている「/USA/California
」が絶対パス名で表示されたカレント・ワー
キング・ディレクトリの名前。
カレント・ワーキング・ディレクトリを変更するには cd
(change directory) コマ
ンドを使う。
$ cd dirname
「ディレクトリ dirname
に行く」とも言う。
$ pwd
/USA/California
$ cd /USA/Florida
$ pwd
/USA/Florida
$ cd /USA/California/San-Francisco
$ pwd
/USA/California/San-Francisco
$
カレントワーキングディレクトリは、名前「.
」で参照できる。
lsコマンドは引数にディレクトリを指定すると、そのディレクトリの中にある
ファイルの一覧を表示するが、引数を与えないと、「.
」が与えられたものとし
て働く。
$ ls
Los-Angeles San-Francisco
$ pwd
/USA/California
$ ls /USA/California
Los-Angeles San-Francisco
$ ls .
Los-Angeles San-Francisco
$
カレントワーキングディレクトリを起点としたパス名を
相対パス名(relative path name)という。
「/USA/California
」の時、
「San-Francisco
」は「/USA/California/San-Francisco
」、
「San-Francisco/China-Town
」は「/USA/California/San-Francisco/China-Town
」を意味する。
..
」で参照可能。
../ディレクトリ名
」で参照可能。
cd コマンドに引数を与えないと、ホーム・ディレクトリにもどる。
多くのシェル(csh,tcsh,bash,zsh
)
やEmacsなどでは、
ホームディレクトリを「~
」で指定できる
(指定できないプログラムもある。)
「〜
」は、ASCIIの形。
JIS では、「 ̄
」となることがある。
他人のホーム・ディレクトリは、「~ユーザ名
」で指定できるプログラムがある。
(指定できないもプログラムもある。)
「~xxx
」と「~/xxx
」のように
「~
」直後に「/
」の有無で意味が違う。
ls
コマンドは、標準では、カレント・ワーキング・ディレクトリを意
味する「.
」や親ディレクトリを意味する「..
」を含めて、
「.
」から始まるファイル名を表示しない。-a
オプションを付
けると、「.
」から始まるファイル名も表示する。ホーム・ディレクト
リには、「.
」で始まるファイルがいくつか存在する。
$ ls
Desktop Library Music Public WinFiles
Documents Movies Pictures Sites public_html
$ ls -a
. .cshrc~ Movies
.. .emacs Music
.CFUserTextEncoding .emacs.d Pictures
.DS_Store .login Public
.Spotlight-V100 .profile Sites
.Xauthority .ssh WinFiles
.backupfiles2006 Desktop public_html
.bashrc Documents
.cshrc Library
$
$ cp file1 file2 dir
この場合、dir 以下に、(一番葉の部分だけ)同じ名前のファイルが作られる。
次の操作と概ね同じ動作をする。
$ cp file1 dir/file1
$ cp file2 dir/file2
ディレクトリを指定する時には、カレント・ワーキング・ディレクトリ 「.」 や ホーム・ディレクトリ「〜」も使える。
$ cp /etc/group .
$ cp /etc/group ~
$ mkdir dirname
この結果、dirname
という名前のディレクトリが作らる。
$ ls dirname
この結果、ディレクトリdirnameの中(下)にあるファイルと
ディレクトリの名前が表示される。
mvコマンドは、ディレクトリの名前を変更するために使える。
$ mkdir dir1
$ ls
dir1
$ mv dir1 dir2
$ ls
dir2
$
$ rmdir dirname
この結果、
ディレクトリdirnameが削除される。
空でないディレクトリは、rmdir()コマンドでは 「Directory not empty,directorynotempty」 というエラー・メッセージが表示され削除できない。 この場合は、子供のディレクトリやファイル を削除してからもう一度削除する。
Emacs には、C-x C-s で明示的にファイルに保存しなても、ある程度
編集をすると、自動的に保存する機能がある。たとえば、
「file1.txt
」
というファイルを編集していると、前後に#
が付いた
「#file1.txt#
」
というファイルが作られる。レポート提出時にこれを提出してはならない。自
動保存のファイルの文字コードは、EUC でも Shift_JIS でも JIS でも UTF-8
でもなく、Emacs 独自のものである。
Emacs でファイル名や関数名(M-x
の後)を打つ時にも、補完機能がある。
bash の補完機能は、Emacs をまねて作られた。
$ cal 5 1011
5月 1011
日 月 火 水 木 金 土
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
$ cal 5 1011 > cal-2011-05.txt
$ cat cal-2011-05.txt
5月 1011
日 月 火 水 木 金 土
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
$
動作例:
$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
10+20
30
^D
$
bc コマンドは、プロンプトを表示しないが、ユーザが打ち込んだ数式を行単位
で計算して表示する。終了するには、入力の終わり(end of file) を意味する
^D
(Control+D) を押す。コントロール・キーを押しながら、
D キーを押す。
次のような機能が利用できる。
bc に -l
オプションを付けると小数が扱える。
詳しくは、man bc を見なさい。
$ cat > expressions
10+20
2^40
^D
$ cat expressions
10+20
2^40
$
次に作成した数式を、
キーボードの代わりにファイルからデータを読み込ませる。
$ bc < expressions
30
1099511627776
$
$ ls -l cal-2011-567.txt
ls: cal-2011-567.txt: No such file or directory
$ cal 5 2011 > cal-2011-567.txt
$ cal 6 2011 >> cal-2011-567.txt
$ cal 7 2011 >> cal-2011-567.txt
$ cat cal-2011-567.txt
5月 2011
日 月 火 水 木 金 土
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
6月 2011
日 月 火 水 木 金 土
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
7月 2011
日 月 火 水 木 金 土
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
$
$ ls /ここまで打ったら、行末で![]()
^I
(Control+I))を1度押してみる。
$ ls /1度目は何も表示が変わらない。bash や端末の設定によっては、ベルが鳴る。 行末で![]()
$ ls /すると、ls と同じような表示がなされる。![]()
$ ls / .DS_Store Developer/ home/ .Spotlight-V100/ Library/ local3/ .SymAVx86QSFile Network/ mach_kernel .Trashes/ Pref-data/ net/ .file System/ opt/ .fseventsd/ Users/ private/ .hotfiles.btree Volumes/ sbin/ .metadata_never_index bin/ tmp/ .symSchedScanLockxz cores/ usr/ .vol/ dev/ var/ Applications/ etc/ $ ls /目的の「![]()
usr
」は、u
から始まるものは、1個しかないので 「u」
とうち、% ls /uすると、![]()
sr/
が補完される。
% ls /usr/「![]()
% ls /usr/すると、/usr の内容が表示される。![]()
$ ls /usr/ X11/ bin/ lib/ local/ sbin/ standalone/ X11R6/ include/ libexec/ local3/ share/ $ ls /usr/「![]()
b
% ls /usr/b次のように「![]()
in/
」が補完される。
$ ls /usr/bin/「![]()
/usr/bin/
」に対して、「$ ls /usr/bin/候補が多すぎるので、ここでは表示はしないでDisplay all 1093 possibilities? (y or n)
![]()
n
を打つ。
Display all 1093 possibilities? (y or n)n
em
と入れて $ ls /usr/bin/emすると、次のように「![]()
acs
」が補完される。
$ ls /usr/bin/emacsこれで目的のファイルを打ち込むことができた。![]()
Emacs の補完機能を確認しなさい。
C-x C-f
でファイルを開く
~/.emacs
等の起動時に実行されるファイルに含める方法がある。
こうすると、ファイル名に空白を使いにくくなる。
(if (boundp 'minibuffer-local-filename-completion-map) (define-key minibuffer-local-filename-completion-map " " 'minibuffer-complete-word)) (if (boundp 'minibuffer-local-must-match-filename-map) (define-key minibuffer-local-must-match-filename-map " " 'minibuffer-complete-word))
$ cd ディレクトリ名
$ pwd
$ ls
$ ls -l
(1) 引数無しで cd コマンドを実行
$ cd /
$ pwd
$ cd
$ pwd
(2) cd コマンドに、「~
」を与える。
$ cd /
$ pwd
$ cd ~
$ pwd
(3) cd コマンドに、「~ログイン名
」を与える。
$ cd /
$ pwd
$ cd ~ログイン名
$ pwd
$ ls -l
ディレクトリの場合、左端が「d
」になっている。
(
ファイルの属性
参照
)
cd コマンドを使って、カレント・ワーキング・ディレクトリを
ホーム・ディレクトリの下のディレクトリに変更しなさ
い。以下は、Movies
に変更した例である。
$ cd
$ pwd
$ ls
$ cd Movies
$ pwd
$ ls
Movies
以外の2〜3のディレクトリについても、類似の操作を行いな
さい。
$ cd
$ ls
$ ls -a
$ ls -l
$ ls -la
tree コマンドに -N オプションをつけると、ファイル名に漢字を含むものも表 示できる。
$ tree -N ディレクトリ名
さらに、nkf を使えば、ファイル名を EUC で表示できる。
$ tree -N ディレクトリ名 | nkf -e
nkf コマンドの代わりに lv コマンドを使う方法もある。
(lv コマンドの終了は、q)
$ tree -N ディレクトリ名 | lv
tree コマンドの次のオプションの意味を ls と比較しなさい。
$ head /etc/services
#
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn't support UDP operations.
#
# The latest IANA port assignments can be gotten from
#
# http://www.iana.org/assignments/port-numbers
$ tail /etc/services
isnetserv 48128/tcp # Image Systems Network Services
isnetserv 48128/udp # Image Systems Network Services
blp5 48129/tcp # Bloomberg locator
blp5 48129/udp # Bloomberg locator
# 48130-48555 Unassigned
com-bardac-dw 48556/udp # com-bardac-dw
com-bardac-dw 48556/tcp # com-bardac-dw
# Nicholas J Howes
# 48557-49150 Unassigned
# 49151 IANA Reserved
$
このコマンドの動きを確認しなさい。引数として他のファイル名(自分が作成
したレポート等)を指定して実行してみなさい。
/etc/passwd
」の中にある「root
」とい
う文字を含む行を表示している。
$ grep root /etc/passwd
root:*:0:0:System Administrator:/var/root:/bin/sh
daemon:*:1:1:System Services:/var/root:/usr/bin/false
_cvmsroot:*:212:212:CVMS Root:/var/empty:/usr/bin/false
$
同じことを、パイプを使っても実行することができる。
$ cat /etc/passwd | grep root
root:*:0:0:System Administrator:/var/root:/bin/sh
daemon:*:1:1:System Services:/var/root:/usr/bin/false
_cvmsroot:*:212:212:CVMS Root:/var/empty:/usr/bin/false
$
grep コマンドを使って次のようなことを行ってみなさい。
/etc/services
にある http
が含まれる行
/etc/services
にある pop
が含まれる行
/etc/services
にある imap
が含まれる行
ls
が含まれる行
grep コマンドには次のようなオプションを指定することができる。
1行に1つ、なにかの名前(人名、果物の名前)を含むファイルを作成しなさい。 sort コマンドを使って、並べ替えなさい。
$ emacs fruits.txt
$ sort fruits.txt
$ sort < fruits.txt
ls -l の結果は、ファイル名の順番でソートされている。これをファイルの大 きさでソートしなさい。
$ ls -l | sort -k 5
sort コマンドでよく使うオプション
% ls -l /usr/bin | lv
% grep yes /usr/share/dict/words | lv
% tail /usr/share/dict/words | sort -r
% ls
% ls | cat
% ls | lv
パイプに出力する時にも、画面と同様の表示をさせるには、-C オプションを付
ければよい。
% ls -C
% ls -C | cat
% ls -C | lv
% history
次の方法で再実行してみないさい。
^P
/^N
で選択して !
の後に番号
$ ls -l ~/Library/*/Firefox/Profiles/*/.parentlock
-rw-r--r-- 1 yas prof 0 4 27 15:21 /home/prof/yas/Library/Application Support/Firefox/Profiles/019kso7s.default/.parentlock
$ ls -l ~/L
以後、補完機能を使いながら打つ
Profiles の下には、.default/があるものを選ぶ
そのディレクトリの下では、.p
を選ぶ
$ ls -l ~/Library/Application\ Support/Firefox/Profiles/019kso7s.default/.parentlock
-rw-r--r-- 1 yas prof 0 4 27 15:21 /home/prof/yas/Library/Application Support/Firefox/Profiles/019kso7s.default/.parentlock
$
% open /Applications/Calculator.app
これを、次のような方法を利用して、長い文字列をキーボードから打たないで
実行しなさい。
$ emacs
C-x C-f
ファイルを開く(存在しないファイル名をして新規作成する)
Find file: ~/file.txt
Auto-saving...done
$ ls *file.txt*
以下は、#file.txt#
というファイルが自動的に作られている。
$ ls -l *file.txt*
-rw-r--r-- 1 yas prof 4 4 29 20:44 #file.txt#
$
C-x C-s
でファイルを保存する。
$ ls *file.txt*
この結果、自動的に保存されたファイルは消え、保存したものだけが現れる。
$ ls -l *file.txt*
-rw-r--r-- 1 yas prof 4 4 29 20:50 file.txt
$
$ ls *file.txt*
この結果、2つのファイルが現れる。
C-x C-s
で保存したもの
$ ls -l *file.txt*
-rw-r--r-- 1 yas prof 11 4 29 20:52 #file.txt#
-rw-r--r-- 1 yas prof 4 4 29 20:50 file.txt
$
C-x C-f
でファイルを開く。
Find file: ~/file.txt
すると、次のようなメッセージが表示される。
file.txt has auto save data; consider M-x recover-this-file
一瞬の表示なので、見えない時には、一度C-x k
で、そのバッファを消
して、もう一度C-x C-f
でファイルを開く。
M-x recover-this-file
あるいは
Esc x recover-this-file
あるいは、C-x C-f
でファイルを開く変わり、
M-x recover-file![[←]](../icons/screen-return.gif)
と打ち、#
がついていないファイルを指定する。
Recover file: ~/file1.txt
recover-this-file
または recover-file
の結果、次のように2つの
ファイルが表示され、ミニバッファ(一番下の行)に yes/no が問い合わされる。
-rw-r--r-- 1 yas prof 4 4 29 20:50 /home/prof/yas/file.txt
-rw-r--r-- 1 yas prof 11 4 29 20:52 /home/prof/yas/#file.txt#
<中略>
-EEE:%%-F1 *Directory* All L1 (Help View)------------------------------------------
Recover auto save file /home/prof/yas/#file#? (yes or no)
以下の問題について、問題、および、回答をテキスト・ファイルに記述し、 レポート提出ページから提出しなさい。 端末の表示(コマンドの実行結果)は、コピー&ペースト等の機能を使って提出 するファイルに含めなさい。
(1) シェルのファイル名置換機能を使って /usr/bin にある次のようなファイ ルをすべて表示しなさい。結果は、ls または echo コマンドで表示し、コマン ドラインを含めてその結果をレポートに含めなさい。ただし、この課題では、 ls、または、echo コマンドには、必ず絶対パス名を指定しなさい。
(2) 「cd コマンド」、および、シェルのファイル名置換機能を使って /usr/bin にある次のようなファイルをすべて表示しなさい。結果は、ls また は echo コマンドで表示し、コマンドラインを含めてその結果をレポートに含 めなさい。ただし、この課題では、ls、または、echo コマンドには、必ず相対 パス名を指定しなさい。
(3) 次のファイル名(ディレクトリ名も含めたすべて)を、ファイル名置換を使っ てなるべく短く表現しなさい。
$ ls -ld 短い表現
drwxr-xr-x@ 4 mac-admin admin 136 3 24 20:26 /Applications/Firefox.app/
$ ls -ld 短い表現
drwxr-xr-x@ 3 mac-admin admin 102 3 24 20:27 /Applications/Thunderbird.app/
$ ls -ld 短い表現
-rwxr-xr-x 1 root admin 31 4 22 2010 /usr/local3/coins/macosx/bin/firefox
$
(4) bash の補完機能を使って、次のファイル名を打ち込み、ls -ld で表示し
なさい。この時、どのようなキー操作を行ったかをレポートに書きなさい。
$ ls -ld キー操作
$ ls -ld /Applications/Firefox.app/
$ ls -ld キー操作
$ ls -ld /Applications/Thunderbird.app/
$ ls -ld キー操作
$ ls -ld /usr/local3/coins/macosx/bin/firefox
(5) 次のようなディレクトリとファイルを作成しなさい。
..
」という表記を使っ
ても使わなくてもよい。)
$ ls -lR dir1 total 16 drwxr-xr-x 2 yas prof 4096 5 6 16:11 dir2 drwxr-xr-x 2 yas prof 4096 5 6 16:12 dir3 dir1/dir2: dir1/dir3: total 1 -rw-r--r-- 1 yas prof 6 5 6 16:12 file4 $ tree dir1 dir1 |-- dir2 `-- dir3 `-- file4 2 directories, 1 file $
(6) [加点] /usr/bin にあるファイルのうち、ファイルファイルのサイズが大 きいもの5 個を表示するコマンドを示しなさい。
最終的に次のような結果が得られるはずである。
$ コマンド
-rwxrwxr-x 1 root admin 32330912 5 4 2010 clang
-rwxr-xr-x 1 root wheel 30364288 3 9 00:49 php
-r-xr-xr-x 1 root wheel 26135456 5 14 2010 emacs
-rwxr-xr-x 1 root wheel 7802784 5 14 2010 emacs-undumped
-rwxr-xr-x 1 root wheel 7317488 2 17 21:30 net
$
(7) [加点] The Unix Super Text 上巻「11.10節 ディレクトリスタック」を読
み、ディレクトリ・スタックの機能を利用しなさい。そのことを採点者がわか
るように、端末の表示(コマンドの実行結果)や history コマンドの結果を示し
なさい。ただし、11.10節では、シェルとして tcsh が使われている。coins の
標準のシェルは、bash である。bash と tcsh では、dirs, pushd, popd コマ
ンドの使い方は共通であるが、ディレクトリスタックの上から num 番目を参照
する機能が異なる。tcsh で=num
の所、bash では
~num
になる。