LPIC/101/GNU_UNIXコマンド/問題

Last-modified: 2006-11-29 (水) 00:32:24

1.単数

「/etc/inetd.d/network stop」とした後に、「/etc/inetd.d/network start」としたい場合、どのコマンドを実行すればよいか?

!!start>>stop
!(start>stop)
!!(start||stop)
^stop^start
!!`stop`<`start`

2.単数

テキストファイルを印刷するために、ヘッダの付加と段落処理などの整形をして出力したい場合に利用するコマンドはどれか?

sed
tr
lpc
pr
head

3.複数

chat.log ファイルのすべての行頭に "> " (引用符) を付けて表示したい。

元ファイル:abcdefg
表示 :> abcdefg

以下のどのコマンドの組合せを実行すればよいか?

cat chat.log > sed s/^/'> '/
sed 's/^/'> '/ < cat chat.log
cat chat.log | sed s/^/'> '/
cat chat.log > sed "s/^/'> '/g"
sed -f chat.log -e s/^/"> "/
sed -e s/^/'> '/g < chat.log

4.複数

下記は、/etc/passwd の一部である。

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:
daemon:x:2:2:daemon:/sbin:
adm:x:3:4:adm:/var/adm:

これを加工して、ログイン名とホームディレクトリのみ表示するには、以下のどれを実行すればよいか?

cut -f1,6 /etc/passwd
cut -f 1,6 /etc/passwd
/etc/passwd > cut -f1,6 -d:
cut -d: -f1,6 /etc/passwd
cut -d: -f 1,6 < /etc/passwd

5.単数

ファイル FILE.txt の内容をアルファベット順にソートするコマンドはどれか?

sort -a FILE.txt
sort -n FILE.txt
sort -r FILE.txt
sort FILE.txt

6.複数

2つのファイルを、file1 、file2 の順に繋げて1つのファイルにするには、どのコマンドを用いればよいか。

cat file2 file1 >> file3
cat file2 >> file1
cat file1 file2 > file3
cat file1 >> file2

回答

番号答え
14
24
33,6
44,5
54
62,3