unix(在bash shell中)的shell脚本,用于将文件从一个位置(即目录)复制到另一个位置,而不使用cp命令

时间:2022-11-15 20:05:26

Can anyone help me with a shell script in unix(in bash shell) for copying a file from one location(i.e a directory), to other, without using cp command at all(not using it in the script also.Any other command /utility can be used in the script).Can it be really done ? I could'nt find a way out.Any help would be appreciated...

任何人都可以帮助我在unix(在bash shell中)使用shell脚本将文件从一个位置(即目录)复制到其他位置,而不使用cp命令(也不在脚本中使用它。任何其他命令/实用程序可以在脚本中使用)。真的可以吗?我无法找到出路。任何帮助都会受到赞赏......

4 个解决方案

#1


1  

How many options do you want?

你想要几个选项?

  • rcp
  • scp
  • dd
  • perl
  • python
  • cat
  • while / read / echo
  • while / read / echo

That is nowhere near exhaustive. You can be creative...have fun!

这远不是详尽无遗的。你可以有创意......玩得开心!

You could use:

你可以使用:

  1. cat to create a C source file, copy.c
  2. cat创建一个C源文件copy.c

  3. make or cc to compile it
  4. make或cc编译它

  5. And then run it to do the copying.
  6. 然后运行它来进行复制。

You could use:

你可以使用:

  1. cat /usr/bin/cp > x
  2. cat / usr / bin / cp> x

  3. chmod +x x
  4. chmod + x x

  5. ./x old new
  6. ./x旧的新

But that is probably cheating.

但这可能是作弊。

#2


3  

Presumably you can cat and redirect the output. Since this sounds like homework, I'll leave it to you to work out the exact syntax.

大概你可以cat并重定向输出。因为这听起来像家庭作业,我会留给你来弄清楚确切的语法。

#3


0  

Erghm. Why?! Anyway...

Erghm。为什么?!无论如何...

cat file1 > some/other/dir/file2

#4


0  

install is a good one.

安装是一个很好的。

#1


1  

How many options do you want?

你想要几个选项?

  • rcp
  • scp
  • dd
  • perl
  • python
  • cat
  • while / read / echo
  • while / read / echo

That is nowhere near exhaustive. You can be creative...have fun!

这远不是详尽无遗的。你可以有创意......玩得开心!

You could use:

你可以使用:

  1. cat to create a C source file, copy.c
  2. cat创建一个C源文件copy.c

  3. make or cc to compile it
  4. make或cc编译它

  5. And then run it to do the copying.
  6. 然后运行它来进行复制。

You could use:

你可以使用:

  1. cat /usr/bin/cp > x
  2. cat / usr / bin / cp> x

  3. chmod +x x
  4. chmod + x x

  5. ./x old new
  6. ./x旧的新

But that is probably cheating.

但这可能是作弊。

#2


3  

Presumably you can cat and redirect the output. Since this sounds like homework, I'll leave it to you to work out the exact syntax.

大概你可以cat并重定向输出。因为这听起来像家庭作业,我会留给你来弄清楚确切的语法。

#3


0  

Erghm. Why?! Anyway...

Erghm。为什么?!无论如何...

cat file1 > some/other/dir/file2

#4


0  

install is a good one.

安装是一个很好的。