No Next Item No Next Conference Can't Favor Can't Forget Item List Conference Home Entrance    Help
View Responses


Grex Info Item 9: An intro to some Unix commands (longish)
Entered by popcorn on Tue Nov 10 04:39:16 UTC 1992:

This item text has been erased.

139 responses total.



#1 of 139 by power on Wed Nov 11 01:23:35 1992:

  Wow!  That must have taken some time to write up!  Good job!


#2 of 139 by popcorn on Wed Nov 11 04:32:09 1992:

This response has been erased.



#3 of 139 by kentn on Thu Dec 24 20:52:39 1992:

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).


#4 of 139 by robh on Thu Dec 24 22:57:48 1992:

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.


#5 of 139 by power on Fri Dec 25 00:49:43 1992:

   Or another way is to put a
rm .newsrc
   in your .logout file....


#6 of 139 by kentn on Fri Dec 25 07:00:25 1992:

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.


#7 of 139 by power on Fri Dec 25 20:49:07 1992:

   (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...


#8 of 139 by davel on Fri Dec 25 23:09:22 1992:

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?)


#9 of 139 by kentn on Sat Dec 26 04:09:40 1992:

(I don't know...whatever works, I'm just not sure how to do it without
getting an error).


#10 of 139 by davel on Sat Dec 26 11:27:45 1992:

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.


#11 of 139 by kentn on Sat Dec 26 21:06:48 1992:

Thanks, I'll give those ideas a try.


#12 of 139 by kentn on Sun Dec 27 04:12:36 1992:

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...


#13 of 139 by tsty on Sun Dec 27 08:34:27 1992:

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 ...


#14 of 139 by tsty on Sun Dec 27 08:36:09 1992:

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.


#15 of 139 by davel on Sun Dec 27 18:59:23 1992:

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".


#16 of 139 by kentn on Mon Dec 28 01:42:12 1992:

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?


#17 of 139 by kentn on Mon Dec 28 06:41:32 1992:

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).


#18 of 139 by robh on Mon Dec 28 22:37:56 1992:

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?


#19 of 139 by glenda on Mon Dec 28 23:59:40 1992:

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.


#20 of 139 by kentn on Tue Dec 29 02:55:02 1992:

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'?


#21 of 139 by davel on Tue Dec 29 14:56:59 1992:

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.


#22 of 139 by robh on Tue Dec 29 22:31:05 1992:

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.


#23 of 139 by kentn on Wed Dec 30 01:11:05 1992:

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.


#24 of 139 by davel on Wed Dec 30 02:24:44 1992:

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.


#25 of 139 by tsty on Wed Dec 30 08:37:12 1992:

   <<yeh, that woulda been, uh, tough ...>>


#26 of 139 by kentn on Thu Dec 31 06:09:37 1992:

   <<or very entertaining...>>


#27 of 139 by popcorn on Sat Jan 2 16:26:44 1993:

This response has been erased.



#28 of 139 by remmers on Sat Jan 2 16:41:44 1993:

Interesting.  I didn't know about the backslash trick for overriding
aliases.


#29 of 139 by kentn on Sat Jan 2 20:21:07 1993:

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.


#30 of 139 by davel on Sat Jan 2 21:34:18 1993:

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.


#31 of 139 by popcorn on Sun Jan 3 09:35:42 1993:

This response has been erased.



#32 of 139 by remmers on Sun Jan 3 13:42:53 1993:

Heh.  There's a file in /bin named '[' that's a link to 'test'.
(sh might also recognize the [] syntax internally)


#33 of 139 by popcorn on Sun Jan 3 17:07:52 1993:

This response has been erased.



#34 of 139 by kentn on Sun Jan 3 21:50:21 1993:

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?


#35 of 139 by kentn on Sun Jan 3 21:57:43 1993:

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?


#36 of 139 by davel on Sun Jan 3 23:26:20 1993:

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 ... .


#37 of 139 by kentn on Mon Jan 4 04:09:20 1993:

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.


#38 of 139 by power on Mon Jan 4 19:36:50 1993:

   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..... :)


#39 of 139 by rcurl on Sun Feb 14 06:53:25 1993:

What and where is that file in which is listed the conferences I follow
automatically? I forgot.


Next 40 Responses.
Last 40 Responses and Response Form.
No Next Item No Next Conference Can't Favor Can't Forget Item List Conference Home Entrance    Help

- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss