简体   繁体   中英

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 ? I could'nt find a way out.Any help would be appreciated...

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.

How many options do you want?

  • rcp
  • scp
  • dd
  • perl
  • python
  • cat
  • 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. make or cc to compile it
  3. And then run it to do the copying.

You could use:

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

But that is probably cheating.

Erghm. Why?! Anyway...

cat file1 > some/other/dir/file2

install是一个很好的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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