csh: still trying to read file
Michael Stanley
jms at hcx.uucp
Sat Apr 1 17:41:25 AEST 1989
In article <2130 at pikes.Colorado.EDU>, pklammer at pikes.Colorado.EDU (Peter Klammer) writes:
> Thank you all; yes, I know $< can accept a line from stdin.
> But what I want is to read a file a line at a time in the
Well, I'm surprised no one has answered this one by now. My answer
may not be the best solution, but it WILL work. Keep a variable which
is the number of the next line you plan to read. Each time you read
a line, you can add one to it. Now, knowing the line number, how do I
get that line from a file... Try this:
set file_name = "TESTFILE"
set line_no = "5"
set line_buff = `sed -n "${line_no}p" $file_name`
echo $line_buff
As usual, I'm lazy and haven't tested this, but I've done stuff like
this before. It isn't pretty but it'll work.
> Another csh mystery (at least until I get my book, maybe): if I prepare
> a csh script file (with the mandatory "#" on line 1) and chmod +x it,
> and then invoke it from a subdirectory, it is run from my HOME directory!
If I understand what you are asking, you want to be able to run your new
command from any directory as if it were a system command. The best way
to do this is to create a directory off YOUR main directory (call it 'bin')
and add that directory to your PATH environment variable (which SHOULD be
set in your .login file as this is a login parameter which is usually set
once and then left alone). An example command to set your PATH from your
.login file might be as follows (watch out because every UNIX system
seems to have a slightly different set of directories for their system
binaries). But over all it should be close to this:
setenv PATH "/bin:/usr/bin:/usr/local:~yourid/bin"
Notice the important part '~yourid/bin'. This says that after all the
system directories are searched to locate a command, YOUR 'bin' directory
will be searched.
Hope this helps and isn't too vague.
Michael Stanley (...!uunet!harris.cis.ksu.edu!jms at hcx)
More information about the Comp.unix.questions
mailing list