小编Git*_*Gud的帖子

Copying files interactively: "cp: overwrite"

I'm trying to figure out what words does the -interactive option of cp accepts as input.

For your convenience, here's code that sets up files for experimentation.

touch example_file{1..3}
mkdir example_dir
cp example_file? example_dir
cp -i example_file? example_dir
Run Code Online (Sandbox Code Playgroud)

The shell then asks interactively for each file whether it should be overwritten. It seems to accept all sorts of random input.

cp: overwrite 'example_dir/example_file1'? q
cp: overwrite 'example_dir/example_file2'? w
cp: overwrite 'example_dir/example_file3'? e
Run Code Online (Sandbox Code Playgroud)

I tried looking into the source code …

shell cp interactive

3
推荐指数
1
解决办法
1253
查看次数

类型强制 PATH 搜索的问题

这是巴什。这种行为在鱼类中是相似的。

$ which python
/usr/bin/python
$ alias py=python
$ type py
py is aliased to `python'
Run Code Online (Sandbox Code Playgroud)

?然后,运行type -P py什么也不打印,正如我所期望的那样以/usr/bin/pyton与下面看到的类似的方式打印。?

$ type ls
ls is aliased to `ls --color=auto'
$ type -P ls
/bin/ls
Run Code Online (Sandbox Code Playgroud)

-P选项的文档读取

  -P        force a PATH search for each NAME, even if it is an alias,
    builtin, or function, and returns the name of the disk file
    that would be executed
Run Code Online (Sandbox Code Playgroud)

我已经确认/usr/bin(所在的目录python)在PATH.

这里发生了什么?

bash fish shell-builtin

3
推荐指数
1
解决办法
225
查看次数

标签 统计

bash ×1

cp ×1

fish ×1

interactive ×1

shell ×1

shell-builtin ×1