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:
你可以使用:
-
cat
to create a C source file, copy.c -
make
orcc
to compile it - And then run it to do the copying.
cat创建一个C源文件copy.c
make或cc编译它
然后运行它来进行复制。
You could use:
你可以使用:
- cat /usr/bin/cp > x
- chmod +x x
- ./x old new
cat / usr / bin / cp> x
chmod + x x
./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
#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:
你可以使用:
-
cat
to create a C source file, copy.c -
make
orcc
to compile it - And then run it to do the copying.
cat创建一个C源文件copy.c
make或cc编译它
然后运行它来进行复制。
You could use:
你可以使用:
- cat /usr/bin/cp > x
- chmod +x x
- ./x old new
cat / usr / bin / cp> x
chmod + x x
./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