![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
|
csh suppress output; newbie question
This is a simple question, but it's giving me problems...
I have: if( -e $HOME/*.core ) then
rm -f $HOME/*.core &> /dev/null
else
echo "No core file"
endifHow can I suppress the output from the rm command? Thanks in advance. Last edited by jolok; Apr 19th, 2005 at 2:42 PM. |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Feb 2005
Posts: 64
Rep Power: 4
![]() |
redirect STDERR
apparently in csh there is no standard way to do it, but there are ways.. http://www.codecomments.com/Unix_Pro...age452517.html Last edited by spydoor; Apr 19th, 2005 at 3:28 PM. |
|
|
|
|
|
#3 |
|
Newbie
|
I should've mentioned that I tried that, first.
if( -e $HOME/*.core ) then
rm -f $HOME/*.core 2> /dev/null
else
echo "No core file"
endif/home/<user>/*.core: no match ![]() And, from man rm(1): -f Attempt to remove the files without prompting for confirma- tion, regardless of the file's permissions. If the file does not exist, do not display a diagnostic message or modify the exit status to reflect an error. The -f option overrides any previous -i options. So it shouldn't echo stderr anyway, should it? Also, redirecting both stderr and stdout (which I was trying to do incorrectly in the first example) doesn't help, either: if( -e $HOME/*.core ) then
rm -f $HOME/*.core >& /dev/null
else
echo "No core files to delete"
endifthe 'else' never gets a chance... I'll try again without any redirection... No dice. Same result. Also, from the command line (csh) rm displays the same behavior. JoloK Last edited by jolok; Apr 19th, 2005 at 4:00 PM. |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Feb 2005
Posts: 64
Rep Power: 4
![]() |
sorry, I was thinking ksh.
I editied my post what you want is, >& also yes, It looks like with -f there should be no error msg to worry about. Maybe I should've left this one to someone with more knowledge...... |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Feb 2005
Posts: 64
Rep Power: 4
![]() |
Okay the -f does suppress the error message.
The /home/<user>/*.core: no match (-e $HOME/*.core) |
|
|
|
|
|
#6 |
|
Newbie
|
Ah! Ok, I was orginally trying different test variables there... I'll work on it from that angle. Thanks, spydoor!
JoloK |
|
|
|
|
|
#7 |
|
Programmer
Join Date: Feb 2005
Posts: 64
Rep Power: 4
![]() |
Here's a nasty solution.... There must be much better ways
count the number of files that match *.core... ignore 'No match'... (to be correct you would also have to ignore other find error msgs like Permission denied.....) if(`find $HOME/*.core |& grep -v 'No match' | wc -l`) then
echo found some
else
echo didn\'t find any
endif |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|