what is the difference between Touch & cat command

Answers were Sorted based on User's Feedback



what is the difference between Touch & cat command..

Answer / manikantan t s

touch :- This can be used to create a file with size 0 and
to change the time stamp of a file.

cat :- This can be used to display the content of a
file,concatinate etc.

Is This Answer Correct ?    85 Yes 7 No

what is the difference between Touch & cat command..

Answer / sivakumar

By using CAT command, we can easily create a new file or
view the file.

Touch command is mainly used for creating a empty file. We
cannot insert any content into this file. File storage is 0
bytes of memory.

Is This Answer Correct ?    92 Yes 17 No

what is the difference between Touch & cat command..

Answer / sivasankar.s

cat command displays the contents of the file.

Ex :
$ cat fruits.txt
apple
orange
grapes

touch command changes the modified date and time of the
file.

before use touch command
$ls -ltr
-rw-r--r-- 1 s aaa 20 Oct 29 16:39 fruits.txt

$ touch fruits.txt

$ls -ltr
-rw-r--r-- 1 s aaa 20 Oct 29 16:51 fruits.txt

Is This Answer Correct ?    56 Yes 12 No

what is the difference between Touch & cat command..

Answer / prasanta

Both touch and cat commands are used to create a file.
but file created by touch will be of 0 byte i.e we can not
insert any data into the file and by using cat command we
can insert data into the file.

the advantage of touch command is that we can create as many
as possible files in a single command line.
ex:touh file1 file2 file3 file4...but we cannot do this
thing by using create command.

prasant kumar
prasantmuna@gmail.com

Is This Answer Correct ?    44 Yes 7 No

what is the difference between Touch & cat command..

Answer / guest

Touch creates a file or files
cat prints the file or displays

Is This Answer Correct ?    45 Yes 20 No

what is the difference between Touch & cat command..

Answer / shruthi

with cat one can perform following:
1. copy
$cat file1 > file2
2. display
$cat file1
3. create
$cat > file1
4. append
$cat file1 >> file2

with touch command one can create a file of 0 bytes later
you can use it like any other regular files. it is not
replacement for cat. but yet another command.
you cannot perform copy(redirection), display and
concatenation with touch.

which command to use, depends on what is your requirement.
say, you are installing oracle and you have not given proper
permission to oracle users home directory, in that case just
to check it, you can use touch command. here you are
interested in knowing whether you as a oracle user have
permission to write to that directory and not in creating a
file with some contents which you will use in future to do
some manipulation.

Is This Answer Correct ?    25 Yes 2 No

what is the difference between Touch & cat command..

Answer / narendrasairam

cat - command is used to display the content of a file
touch - command is used to change the time stamp of a file

Is This Answer Correct ?    27 Yes 5 No

what is the difference between Touch & cat command..

Answer / lafir gk

touch:- This can be used to create a file with size 0 and
to change the time stamp of a file.

cat:- This can be used to display the content of a
file,concatinate etc.

Ex :
# cat Example.txt
AIX
HPUX
SOLARIS
LINUX

touch command changes the modified date and time of the
file.

before use touch command
#ls -ltr
-rw-r--r-- 1 s file1 02 Nov 29 19:24 Example.txt

# touch Example.txt

#ls -ltr
-rw-r--r-- 1 s file1 02 Nov 29 19:43 Example.txt

Is This Answer Correct ?    12 Yes 3 No

what is the difference between Touch & cat command..

Answer / shan, chennai

Cat:-
Using the cat command, we will be able to create the new
file as well as put the required ocntent inside the files
(CNTL+d to come out the file after putting the content). At
a time only one file can create.

Touch:-
Using this command, we can create the more than one file at
a time without inserting the content (So file size will be
always ZERO).

Example:
$cat > test11.js
$touch test1.ls test2.js test3.js

Shan, Chennai

Is This Answer Correct ?    10 Yes 3 No

what is the difference between Touch & cat command..

Answer / abhishek dilliwal

cat is for concatenation of 2 or more files if used over
single file it simply displays its contents

touch is used for modifying the time stamp of a file, also
used for making empty files

try,
$touch file{1,2,3,4}
to create 4 files as: file1, file2,..

Is This Answer Correct ?    13 Yes 7 No

Post New Answer

More Unix Commands Interview Questions

what is ls -ltd?

5 Answers   HCL,


What happens when we execute a unix command?

0 Answers  


Give the command for finding the current date.

0 Answers  


What do chgrp command do?

0 Answers  


Is there any command in Unix, other than:ls, to list the files in a directory? The answer will be highly appreciated...

27 Answers   CGI,






what is the advaantage of each user having its own copy of the shell?

2 Answers   Infosys,


Describe the usage and functionality of the command rm –r * in unix?

0 Answers  


how to find largest file?

14 Answers   HCL, Microsoft, Thomson Reuters,


what are the different commands used to view the contents of a file?

5 Answers  


distinguish between paging and swapping?

3 Answers   Infosys,


what is the command to list files in a directory in UNIX?

8 Answers  


use of ls command

9 Answers  


Categories