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

distinguish between physical addresses and logical address?

3 Answers   Infosys,


How to replace the exact word in vi editor?? suppose a file contains words like amaze,amazed,amazement in some of the line.But i want to replace only 'amaze' with delight but don't wanna replace amazed or amazement. thanks

6 Answers   Polaris, Tech Mahindra,


How to display a file name which has zero bytes in size.

11 Answers   Polaris,


Write a command to find all of the files which have been accessed within the last 30 days.

5 Answers   Google, IBM, Satyam,


How to know a process is a zombie or orphan process?

3 Answers   Perot Systems,






Which command is used to find whether the system is 32 bit or 64 bit?

0 Answers  


Differentiate cmp command from diff command.

0 Answers  


what is the difference between SED and GREP ? Which one is more better and why?

4 Answers   IBM,


What are awk commands?

0 Answers  


what is the cmd to display the last exit status in UNIX?

5 Answers   MEIT, Syntel,


What do chown command do?

0 Answers  


Who command in unix operating system?

0 Answers  


Categories