|
|
This item text has been erased.
139 responses total.
Wow! That must have taken some time to write up! Good job!
This response has been erased.
Annoying Unix question of the day: I've been using trn to read usenet news. Great. However, every time I quit trn, it saves a file called '.oldnewsrc' which I always delete (to save disk space). Is there a command to put in my .login or .cshrc that would check to see if '.oldnewsrc' exists and if so, rm it? (I'd like this to be automatic).
I just have a "nohup rm .oldnewsrc &" command in my .logout file. If I haven't read any news during the session, big deal, it gives a "file not found" error message and keeps on going.
Or another way is to put a rm .newsrc in your .logout file....
You mean rm .oldnewsrc...I *want* my .newsrc to hand around (I don't want to go through three hours of it asking me if I want to add such and such a newsgroup). I was hoping to find a way to do this that avoids getting an error message when the file doesn't exist.
(oh yeah... Oh well, you know what I mean :) )... putting the rm .oldnewsrc doesn't give an error message when there isn't one, I don't think... (I almost always run trn when I get on, so I'm not sure if I'd know, but I don't think I've noticed it doing so...)... Even if it does, it would come right before the NO CARRIER message, so it's not like it's really annoying... and you could always redirect it to /dev/null...
If you're going to redirect it to /dev/null, I'm pretty sure it's 2>/dev/null (stderr, not stdout). (And either the redirection or a test for existence or a pre-creation is indeed necessary if rm is not to give you a message. Would you settle for a line >.oldnewsrc which would create the file if it didn't exist but cut it to 0 bytes if it did, instead of (or before) the rm?)
(I don't know...whatever works, I'm just not sure how to do it without getting an error).
If you just do "rm .oldnewsrc" you'll get an error if it doesn't exist, but as others noted the error shouldn't do any harm. If you just don't want to see error messages, "rm .oldnewsrc 2>/dev/null" will send any error messages down the black hole. This should be fine; in general I disapprove a teeny little bit, as (if something truly weird were to happen) you wouldn't see any other error messages either; but there *shouldn't* be any. Or you can just wipe the thing down to nothing with "> .oldnewsrc", or create/wipe it & *then* delete it with "> .oldnewsrc;rm .oldnewsrc". Any of these should work and be acceptable.
Thanks, I'll give those ideas a try.
Well...my experiences have been: >.oldnewsrc gives an error about a bad null (and doesn't create anything). rm will delete .oldnewsrc but not without asking me if I want to (even when I use the -f switch). I tried cp .newsrc .oldnewsrc and the rm .oldnewsrc, and that gives me a .oldnewsrc to delete (although quite a bit bigger than 0 bytes!). the 2>/dev/null gives me an error, as does >/dev/null (the latter hangs). I pretty puzzled why rm -f doesn't work. Isn't -f supposed to override the -i query? If rm would work like it's supposed to I could probably learn to ignore the error...
Whata it says inthe manual ...
NAME
rm, rmdir - remove (unlink) files or directories
SYNOPSIS
rm [ -r ] [ -f ] [ -i ] [ - ] _^Hf_^Hi_^Hl_^He_^Hn_^Ha_^Hm_^He ...
DESCRIPTION
Rm
_^Hr_^Hm removes (directory entries for) one or more files. If an
-f Force files to be removed without displaying permis-
sions, asking questions or reporting errors.
so kentn should expect rm to work as advertised, I would think ...
The only "error" I can think of would be if the file named did not exist, then an error would be reported, but the manual tends to say that nothing is reported if -f is used. Oh, well ... it's unix.
Hm. The null redirection apparently is only available in sh, not in csh. (My apologies!!!). I can't imagine what the problem with rm is, unless there are two versions lurking on grex and your path is selecting the wrong one. I would suggest that you do "type rm" to find out what you're getting, but type is a builtin command in sh, & I don't think it works with csh. For me, rm is /bin/rm. To cut it down to zero bytes, you might try "cp /dev/null .oldnewsrc".
Well, I guess I could open a Bourne sh and do those commands, but that might make logging out a major multi-step process. Anyway, I thought rm was a part of Unix, not a part of the shell I'm using. Does some systems person have the -f parameter locked out for some reason?
Here's another command question: where's tput? There's a man entry for it, but I can't find it (or make it run).
Kent - I have rm aliased in my .cshrc to 'rm -i', so it automatically asks about deletions for every file. Could you have this set up?
Personally, I wouldn't remove .oldnewsrc. There have been times when, for some reason, my .newsrc got munged and I needed .oldnewsrc to get back into news without having to go through the whole list of groups and re-reading the responses that I had already seen. Sort of like an insurance policy.
Well, since it takes up about 26K, I though I'd get rid of it to help ease the disk crunch. If you people aren't worried about that, then I'll leave it around. As an alternative, I could compress it, but then I'd still have the problem of deleting .oldnewsrc. I don't think I have rm aliased as you say, but even if I do, the manuals (and man) say that rm -f overrides -i, so rm -fi means -f takes precedence. Maybe I should just have .logout reply 'y'?
I personally hope you'll figure out what's going on & let me know - things like this suggest that other problems may crop up. (For one thing, what's your path? if you don't mind posting it or mailing me.) I assume you know it, but JIC: to do as you suggested: echo y | rm .oldnewsrc presumably ought to do it.
Kent, perhaps the best option is to go through and delete the newsgroups you're not reading from your .newsrc. When I did that, it went from 25K to 6K. That'll end up saving more space than rm'ing your .oldnewsrc, and if you want, you can always do both.
Good idea, robh. I've been a bit leery of deleting something that I'll later wish was there, so I haven't chopped the .newsrc down to size. davel, I do have rm aliased as 'rm -i'. I'll try unaliasing it and see if the -f switch works. If it does, then I'll be annoyed that it should work even if rm is aliased... I think my path is okay, at least rm is working fine, except for the questioning I get from -i. I'd really like to leave -i in the alias because I do from time to time delete things without thinking.
Thanks - I am glad to believe that the alias is the cause; I just would have hated to find rm itself behaving in inconsistent ways.
<<yeh, that woulda been, uh, tough ...>>
<<or very entertaining...>>
This response has been erased.
Interesting. I didn't know about the backslash trick for overriding aliases.
I found out on another system (MTS) that doing /usr/bin/rm -f fyle works, so that seems to be along the same lines as popcorn suggests. It's good to know that there is a way to override aliases; thanks.
At least in sh (probably not in csh), you can indeed do a conditional on one line. To do what Valerie suggested (but with the full pathname specified a la Kent's note): if [ -f $HOME/.oldnewsrc ]; then /bin/rm $HOME/.oldnewsrc ; fi The blanks after the "[" and before the "]" are mandatory, as are the semicolons. (As most of you know, the [ ] syntax is equivalent to using test as Valerie did. I find it easier to see what's happening. I expect the man on test gives the options; does on the SYSV I'm used to.
This response has been erased.
Heh. There's a file in /bin named '[' that's a link to 'test'. (sh might also recognize the [] syntax internally)
This response has been erased.
The problem I have now, is that I get an error back from the [] syntax saying that I'm missing ], even though I'm not (as far as I can see). The other form of the test command 'test ...' gives another error about about (what I can't remember)... This is just a .logout file and it's not been changed to an execuble or anything. Does that make a difference?
Oh...it's "if: Expression syntax" I've tried a lot of different ways to enter the expression (multiple lines, combining lines, double checking the man pages, every manual I have concerning test and if in a c-shell, etc.) and had no luck. Any ideas on what silly mistake I'm making? Or do you have a working version of the "if test...\rm .oldnewsrc endif" script?
Kent, if it's csh I'm out of my depth. Sorry. In sh you need some semicolons and a then and it's fi not endif, but I *think* that's because it's sh. Valerie, at least on recent SYSV systems, the link approach is not used; my impression (from something mju once said) is that that's a now-obsolete approach ... .
One of my references said that it was 'endif' for csh, so that's why I tried replacing 'fi' with that. I've tried it both ways and neither way works, so I doubt that that's the problem.
I just have a rm .newsrc in my .logout, and I don't get any file not found messages... Though I start up trn almost every time I get on..... :)
What and where is that file in which is listed the conferences I follow automatically? I forgot.
| Last 40 Responses and Response Form. |
|
|
- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss