LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-07-2011, 03:47 AM   #1
sankarv
LQ Newbie
 
Registered: Jun 2008
Posts: 5

Rep: Reputation: 0
find stderr redirect to variable


Hi,

I am assigning "find" operation output to a variable. I also need to have error info / stderr if nothing is found in the same variable itself.

e.g.

a=`find . -name "hello.txt" -type f`

I do not want any temp files to be in between infact, redirection.

Is there any way?

Thanks.
 
Old 01-07-2011, 04:34 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,255

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
I am not sure I understand the question?? If find does not find the file called "hello.txt" anywhere in the current directory or sub-directories it will return nothing, ie. there will be no error??
 
Old 01-07-2011, 04:42 AM   #3
sankarv
LQ Newbie
 
Registered: Jun 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Hi, You are right. I am trying in csh, well

Sorry My actual issue is, the path given to find command:

"find "path" -name file -type f"

"No such file or directory" is the error, I want it not to get printed on screen if it does not exist when i asign to variable, is it possible without redirecting to files (except /dev/null)

got it?

Thanks
 
Old 01-07-2011, 05:00 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,255

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
Then perhaps test the path exists prior to running command or you can redirect stderr to /dev/null but of course you will still be faced with having
to test something somewhere.
 
Old 01-07-2011, 05:05 AM   #5
sankarv
LQ Newbie
 
Registered: Jun 2008
Posts: 5

Original Poster
Rep: Reputation: 0
exactly, found it, i did the same infact , testing '-d $path' using 'if' condition, thought of asking if something really existing, many thanks for prompt responding, taking me to right direction
 
Old 01-07-2011, 05:38 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,255

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
All good glad you are on your way, please remember to mark as SOLVED once you have a solution.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to redirect stdin and stderr to another terminal... trist007 Linux - Newbie 4 06-29-2010 09:10 AM
Cannot redirect all stdout and stderr into file hawkgao Programming 2 05-12-2009 10:14 AM
redirect stderr to file with a prefix? JPMallory Programming 2 12-26-2007 04:10 PM
bash stderr redirect question code-breaker Linux - Software 1 08-06-2006 05:44 AM
how do i redirect stderr to a file? nodger Programming 5 11-28-2004 12:22 PM


All times are GMT -5. The time now is 07:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration