0

I want to delete a text file from Unix machine. I am using the following command for the same.

rm /tmp/filename.txt

It is working fine. After execution it returns nothing.

I want to get some conformation about deletion as follows,

filename.txt deleted successfuly.

Please any one help me on this.

Thanks in advance.

0

4 Answers 4

1

You can use these commands:

rm /tmp/filename.txt && echo "File successfuly deleted"

this will remove the file and then (only if the exit status of command is successful) print the message.


Otherwise, as Venkat said, you can use rm -i that asks for confirmation before deleting the file.

Sign up to request clarification or add additional context in comments.

Comments

1

I have used the following to slove my issue.

rm -v /tmp/filename.txt

this will display the message as follows,

removed `/tmp/filename.txt`

Comments

0

you can use option with Unix command please See this link below

Comments

0

The below command prompts you once whether you want to remove the file before deleting it.

rm -i tmp/filename.txt

If the file is unavailable shows you :

cannot remove ‘tmp/filename.txt’: No such file or directory

Hope it helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.