简体   繁体   English

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

[英]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

Can anyone help me with a shell script in unix(in bash shell) for copying a file from one location(ie 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 ? 任何人都可以在unix(在bash shell中)中使用Shell脚本来帮助我,以将文件从一个位置(即目录)复制到另一个位置,而根本不使用cp命令(也没有在脚本中使用它)。任何其他命令/实用程序可以在脚本中使用)。真的可以完成吗? I could'nt find a way out.Any help would be appreciated... 我找不到出路,任何帮助将不胜感激...

Presumably you can cat and redirect the output. 大概您可以cat并重定向输出。 Since this sounds like homework, I'll leave it to you to work out the exact syntax. 由于这听起来像作业,所以我将把它留给您来确定确切的语法。

How many options do you want? 您想要几个选择?

  • rcp 钢筋混凝土
  • scp scp
  • dd dd
  • perl 佩尔
  • python 蟒蛇
  • cat
  • while / read / echo while /读/ 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 cat创建一个C源文件copy.c
  2. make or cc to compile it makecc进行编译
  3. And then run it to do the copying. 然后运行它进行复制。

You could use: 您可以使用:

  1. cat /usr/bin/cp > x 猫/ usr / bin / cp> x
  2. chmod +xx chmod + xx
  3. ./x old new ./x旧的新的

But that is probably cheating. 但这可能是作弊。

Erghm. Why?! 为什么?! Anyway... 无论如何...

cat file1 > some/other/dir/file2

install是一个很好的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM