Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem redirecting output of find to a file

Tags:

find

unix

pipe

I am trying to put the result of a find command to a text file on a unix bash shell

Using:

find ~/* -name "*.txt" -print > list_of_txt_files.list

However the list_of_txt_files.list stays empty and I have to kill the find to have it return the command prompt. I do have many txt files in my home directory

Alternatively How do I save the result of a find command to a text file from the commandline. I thought that this should work

like image 961
harijay Avatar asked Oct 26 '10 02:10

harijay


1 Answers

You can redirect output to a file and console together by using tee.

find ~ -name '*.txt' -print | tee result.log

This will redirect output to console and to a file and hence you don't have to guess whether if command is actually executing.

like image 59
Prashant Nidgunde Avatar answered Sep 24 '22 08:09

Prashant Nidgunde