answersLogoWhite

0

#include<sys/types.h>

#include<sys/stat.h>

#include<fcntl.h>

#include<stdio.h>

#include<unistd.h>

#include<string.h>

int main()

{

int fd1,fd2;

char name1[100],name2[100];

char str[6];

int n;

printf("enter name of file to move");

scanf("%s",name1);

printf(enter new location);

scanf("%s",name2);

fd1=open(name1,O_RDONLY);

fd2=open(name2,O_WRONLY);

while(1)

{

n=read(fd1,str,sizeof(str));

printf("%s \n",str);

if(n==0)

break;

write(fd2,str,n);

}

close(fd1);

close(fd2);

unlink(name1);

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

How do you create dummy file in unix?

using touch command of UNIX. syntax touch &lt;filename&gt; will create dummy regular file.


In unix how will you find extension of file using commands?

Unix files do not rely on extensions, therefore there is no command to find them.


The data blocks of a very large file in the Unix file system are allocated using?

an extensioin of indexed allocation


The Unix file contains which kinds of fields?

The Unix file contains which kinds of fields?


How does unix access a file from a directory?

Unix accesses a file from a directory using a hierarchical file system structure. When a command is executed to access a file, the Unix kernel navigates through the directory tree, starting from the root directory, to locate the specified path. Each directory contains entries that map file names to their corresponding inode numbers, which store metadata and point to the actual data blocks on disk. By reading the inode, Unix can access the file's content efficiently.


Without using cp command you copy file to another file in unix?

The easiest way would be: cat file1 &gt; file2


How do you Find size of a file using c program?

OS-dependent.stat for unix, FindFirstFile for Windows.


What is the system file in Unix?

There is no the system file. There are many files necessary to create a working Unix system.


How do you transfer files from unix to windows?

Unix files can be easily transferred to windows via a network connection either by using FTP or by using Samba. Samba allows a Unix file system to be mounted/shared on a Windows system to look like a windows directory.


Where would you find a host file on a unix server?

The host file in Unix is usually located in the /etc directory.


Is Unix a web browser?

Unix is a text file, not a web browser. :)


What has the author Douglas W Topham written?

Douglas W. Topham has written: 'A system V guide to UNIX and XENIX' -- subject(s): UNIX System V (Computer file), XENIX (Computer file) 'The first book of UNIX' 'UNIX and XENIX' -- subject(s): UNIX (Computer file), XENIX