Questions tagged [csh]

csh, or the C shell, is a command interpreter with a syntax reminiscent of the C programming language.

Quoted from the Solaris csh man page:

csh, the C shell, is a command interpreter with a syntax reminiscent of the C language. It provides a number of convenient features for interactive use that are not available with the Bourne shell, including filename completion, command aliasing, history substitution, job control, and a number of built-in commands. As with the Bourne shell, the C shell provides variable, command and filename substitution.

csh first appeared in 2BSD, and was originally created by Bill Joy. While Bourne shells are more popular, csh-style shells are still fairly popular especially in the BSD community & academia.

is an an enhanced version of csh, almost all versions of csh encountered nowadays are actually tcsh.

Programming in csh is a controversial topic. For one viewpoint, see this article.

1173 questions
10
votes
1 answer

How do I escape a field variable in an awk command in an alias?

Here are the contents of a file: one two three four five six And here is my alias alias testawk "awk '{print $2}' file" This is what I get: > testawk one two three four five six But when I give this command, then I get what I want: > awk '{print…
B Johnson
  • 2,408
  • 3
  • 20
  • 32
9
votes
2 answers

`watch jobs` doesn't work in linux

I want to use watch jobs to see an updated showing of all the jobs I have running, but when I try to do it, all I get is the headline of watch and a blank screen. But using the script while (1) sleep 10; clear; jobs; end does work, where is…
SIMEL
  • 8,745
  • 28
  • 84
  • 130
9
votes
3 answers

How can I change my tcsh prompt to show my current working directory?

I am using tcshand I am looking for a way responsive working directory where I at least want to display the last folder name instead of getting full path. Imagine my current working directory is : …
pawankalyan
  • 211
  • 2
  • 3
  • 7
9
votes
2 answers

Call one shell script from another script using relative paths

I have a script like this: #!/bin/csh echo "This is the main programme" ./printsth I want to call the script printsth from within this script using relative paths. Is there a way to do so? By relative paths I mean path relative to where my calling…
Programmer
  • 6,565
  • 25
  • 78
  • 125
9
votes
3 answers

How to redirect stdout and stderr from csh script

For the following script install.csh: #!/bin/csh -f tar -zxf Python-3.1.1.tgz cd Python-3.1.1 ./configure make make install cd .. rm -rf Python-3.1.1 Intended use: ./install.csh |& tee install.log How can I change the script so that I still get…
Shelly Adhikari
  • 93
  • 1
  • 1
  • 3
9
votes
12 answers

How to keep from duplicating path variable in csh

It is typical to have something like this in your cshrc file for setting the path: set path = ( . $otherpath $path ) but, the path gets duplicated when you source your cshrc file multiple times, how do you prevent the duplication? EDIT: This is one…
dr_pepper
  • 1,587
  • 13
  • 28
9
votes
3 answers

How to color a prompt on FreeBSD/cshrc?

I'm being put in charge of managing a bunch of servers, I want to set up my prompts on each of them so that I don't get confused as to where I am logged in to. I've edited my .cshrc files and put this in them: set prompt=`whoami`@`hostname…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
9
votes
2 answers

java.io.IOException: Cannot run program error=2, No such file or directory

I have a java class in which I call a runshellscript method that will execute a script. It worked well with mysql but I cannot seem to find out why it wont work well with psql. Here is an excerpt of my runshell method: public class RunShellScript…
rambokayambo
  • 341
  • 4
  • 10
  • 27
9
votes
6 answers

count number of tab characters in linux

I want to count the numbers of hard tab characters in my documents in unix shell. How can I do it? I tried something like grep -c \t foo but it gives counts of t in file foo.
ravi
  • 3,304
  • 6
  • 25
  • 27
8
votes
1 answer

set command error in c shell script

I am doing this on my script: set Cnt1 =`echo $Cnt | awk '{print $1}'` set Cnt2 =`echo $Cnt | awk '{print $2}'` set Cnt3 =`echo $Cnt | awk '{print $3}'` I am getting a error saying " set: Variable name must begin with a letter." Can someone tell me…
Jack
  • 785
  • 4
  • 12
  • 19
8
votes
4 answers

How to input a comment on csh?

In bash, I used # to input comment. Even on interactive session. bash-3.2$ # bash-3.2$ # bash-3.2$ # bash-3.2$ csh spits error for this. How can I input some comment on interactive csh session? In other words, I am looking for a way to make 100%…
eonil
  • 83,476
  • 81
  • 317
  • 516
8
votes
1 answer

Scope of "setenv" in csh Versus "export" in bash

From what I've read, setenv in csh and export in bash are equivalent. However, I found some strange issues while working with the two. When I open putty and start typing: setenv TEMP yes echo $TEMP //this give me "yes" then I go to bash and…
Dao Lam
  • 2,837
  • 11
  • 38
  • 44
8
votes
1 answer

How to check if an environment variable is either unset or set to the empty string?

I don't want to use tcsh, but unfortunately have no choice in this situation. So please no "use another shell" answers! I'm currently trying to check that an environment variable is both set, and that it's set to something useful. So what I want to…
spookypeanut
  • 503
  • 1
  • 6
  • 24
7
votes
5 answers

How can I get csh to source a file and then go interactive?

BRIEF how do I (1) start a new csh, (2) force it to execute a few commands that are NOT in any .cshrc (although I could arrange for them to be in a non-standard location to be source'ed) and (3) then go interactive? E.g. is there any way to get csh…
Krazy Glew
  • 7,210
  • 2
  • 49
  • 62
7
votes
3 answers

multi-line variable in tcsh

I want to have variable in tcsh to hold the usage info of my script, so in my script, whenever I write echo $usage, it will print my_script -h : -help -b : do boo etc`. Is there a way to do this? Can this be done using the << EOF ? I've tried…
eran
  • 6,731
  • 6
  • 35
  • 52