Sponsored Content
Top Forums Programming Difference between cp and mv linux command Post 302425086 by bigearsbilly on Thursday 27th of May 2010 07:16:23 AM
Old 05-27-2010
well, I suggest you read the source code for cp and mv

well, for a start, cp copies the file, so opens, reads and copies.
mv just moves or renames it. So the actual inode is not accessed,
only the Directory entries.

---------- Post updated at 12:16 PM ---------- Previous update was at 12:10 PM ----------

Quote:
Originally Posted by achenle
The mv command first deletes the target file if it exists. The cp command does not.
no that is wrong.

observe, if I mv (rename) a file the inode
does not change:

Code:
 
cat:$ls -i 1
82309 1
cat:$mv 1 2
cat:$ls -i 2
82309 2

if I do a cp the inodes actually change.

Code:
cat:$ls > 1
cat:$cp 1 2
cat:$ls -i 1 2
82964 1  82967 2

the inode is the physical disk block(s) where the file lives.
you have only updated the directory with a mv
 

9 More Discussions You Might Find Interesting

1. Programming

Difference in LINUX and SOLARIS

/* * one-way-pipe.c - example of using a pipe to communicate data between a * process and its child process. The parent reads input * from the user, and sends it to the child via a pipe. * The child prints the received data to the... (1 Reply)
Discussion started by: SQ4LIFE
1 Replies

2. UNIX for Dummies Questions & Answers

Difference between UNIX and Linux

OK, I've used various versions of UNIX(Solaris, HPUX, etc..) over the years. Now the organization I work for is leaning towards more Linux based systems(Redhat, Suse, etc..) I do see differences in in comands and how to accomplish basic adminstration, but nothing mind blowing. So, what is it... (5 Replies)
Discussion started by: pbonilla
5 Replies

3. UNIX for Dummies Questions & Answers

su command difference between unix and linux

Hello all the su with -l option is running normal with linux but when i try to run it on unix AIX 5.2.7 it's not working with -l option any help (6 Replies)
Discussion started by: islam.said
6 Replies

4. UNIX for Dummies Questions & Answers

difference between unix and linux

Hi I am new to linux I have dout waht is the difference between UNIX and LINUX Is there any soft for insatallation for UNIX OS Thanks (0 Replies)
Discussion started by: sanjaya
0 Replies

5. Linux

Difference between Windows and Linux

Hi, What is the difference between Linux and Windows? Thanks. (1 Reply)
Discussion started by: billcrosby
1 Replies

6. Linux

What is the difference between Linux and Windows?

Hi, What is the difference between Linux and Windows? Thanks. (5 Replies)
Discussion started by: billcrosby
5 Replies

7. UNIX for Dummies Questions & Answers

Difference between UNIX and Linux

hi experts please tell me the real difference between unix and linux at kernel structure (1 Reply)
Discussion started by: linurag
1 Replies

8. Red Hat

Difference Redhat Linux/RH Enterprise Linux

what is the difference between Redhat Linux and Redhat Enterprise Linux. whereas Redhat linux have Server installation options too. (2 Replies)
Discussion started by: hananabbas
2 Replies

9. UNIX for Dummies Questions & Answers

AIX to Linux command difference

Moving from AIX 6.1 to RHEL 6.6, I have noticed a few command differences. One that has been causing issue is a simple echo command when I have to use it this way -> "echo -e" On the AIX it outputs to "-e" but since RHEL has "-e" as an option for echo and hence it outputs to blank here. All... (3 Replies)
Discussion started by: aster007
3 Replies
CAT(1)							      General Commands Manual							    CAT(1)

NAME
cat, read, nobs - catenate files SYNOPSIS
cat [ file ... ] read [ -m ] [ -n nline ] [ file ... ] nobs [ file ... ] DESCRIPTION
Cat reads each file in sequence and writes it on the standard output. Thus cat file prints a file and cat file1 file2 >file3 concatenates the first two files and places the result on the third. If no file is given, cat reads from the standard input. Output is buffered in blocks matching the input. Read copies to standard output exactly one line from the named file, default standard input. It is useful in interactive rc(1) scripts. The -m flag causes it to continue reading and writing multiple lines until end of file; -n causes it to read no more than nline lines. Read always executes a single write for each line of input, which can be helpful when preparing input to programs that expect line-at-a- time data. It never reads any more data from the input than it prints to the output. Nobs copies the named files to standard output except that it removes all backspace characters and the characters that precede them. It is useful to use as $PAGER with the Unix version of man(1) when run inside a win (see acme(1)) window. SOURCE
/src/cmd/cat.c /src/cmd/read.c /bin/nobs SEE ALSO
cp(1) DIAGNOSTICS
Read exits with status eof on end of file or, in the -n case, if it doesn't read nlines lines. BUGS
Beware of and which destroy input files before reading them. CAT(1)
All times are GMT -4. The time now is 11:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy