what is the difference between Touch & cat command
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
Answer / guest
Touch creates a file or files
cat prints the file or displays
Is This Answer Correct ? | 45 Yes | 20 No |
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 |
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 |
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 |
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 |
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 |
what do you understand by 'building block primitive'?
How do you grep a case insensitive?
How to install scsi driver in unix? give me explanation clearly?
distinguish between multi-tasking,multi-user,multi- processing and time sharing?
7 Answers Alcatel, Cisco, Infosys, University Exams,
how to find the 51th record of a file containing 100 records in unix.
Why we are using UNIX OS when we are doing the testing in our application?
What Is the command to change a file's creation time. means one file is created at the time 15:19 then time should br changed to 14:14
Why is grep called grep?
Explain the steps that a shell follows while processing a command.
In UNIX, what is the command to edit contents of the file?
what are filters?
What is a bash command?