レス
元トピ
次レスタイトル
Re: 問題ID:22248
フォーラム
最強WEB問題集LinuC/LPIC Lv1 101
投稿ユーザ(投稿日)
(2020/5/3)本文
-----引用(始)-----
-fを付けた場合とつけない場合で違いはあるのでしょうか。
-----引用(終)-----
こんな違いがあります。
[code]
$ touch testfile
$ chmod 000 testfile
$ ls -l testfile
----------. 1 testuser testuser 0 May 3 22:30 testfile
$ cp /etc/passwd testfile
cp: cannot create regular file ‘testfile’: Permission denied
$ cp -f /etc/passwd testfile
$ ls -l testfile
-rw-r--r--. 1 testuser testuser 2113 May 3 22:31 testfile
[/code]
厳密には、「cp -f」は「だめだったら削除してもう一回やってみる」なんですよね。
-----引用(始)-----
$ man cp
(略)
-f, --force
if an existing destination file cannot be opened, remove it and try again (this option is
ignored when the -n option is also used)
-----引用(終)-----
そういう意味でも、-fオプションの有無で動作は変わるので違いはある、と言えますね。
レス一覧
元トピ
次レス
Copyright (c) 2010
Ping-t All rights reserved.