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

What are awk commands?

582


Explain the terms ‘system calls’ and ‘library functions’ with respect to unix commands?

638


Who wrote grep?

579


What is “chmod” command?

564


What does the command ' $who | sort –logfile > newfile' do?

768






Explain ‘library functions’ with respect to unix commands?

603


What do chmod command do?

602


What do chgrp command do?

590


What does #!/ Bin sh do?

588


What is the first character of the output in ls l command?

631


How to use grep command to list find the records of a file containing 10 different strings?

643


How do I run a whois command?

599


What is in grep command?

647


What command is used to switching between users in unix?

560


Name the general commands in using unix os for a beginner?

623