what is the difference between Touch & cat command

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain command to display different lines that are found when compare two files?

678


How to display no of records in oracle using unix command?

590


What is rmdir command?

555


Who wrote grep?

589


Why is shebang used?

599






What is grep and how do you use it?

581


What does awk stand for?

615


Describe the zip/unzip command using gzip.

615


What is the nmap command?

586


What is the difference between awk and grep?

561


how to sort the content of the file based on numeric values

1256


Explain the steps that a shell follows while processing a command.

683


Can you explain a little bit about command substitution?

612


What is the use of the tee command?

602


How do I search for text in vi?

589