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
0
votes
3 answers

weird behaviour of If statement in (t)csh

I have an if loop that's not quite doing what it's supposed to. I want the if loop to look for a particular file "if (-f JUN*[0-9].acc$RUN.nc)" and if it finds it, continue doing the indented things. If not, it should jump down past the endif and…
0
votes
2 answers

Determine module load status

I have one script which determine the module load status. In the following code Line 4, it give me error that it can not load specific version than after I have check the status. Ideally I should get 1 as a status But it was still zero. Then I have…
user765443
  • 1,856
  • 7
  • 31
  • 56
0
votes
1 answer

A newly defined alias within another alias, the first excution will fail

If we define and use an alias B within another alias A, the first time execution of A will fail. For example, alias A='alias B="which ls"; B;' The first time excution would look like (in bash) bash: B: command not found The example above is a…
Yang Li
  • 1
  • 2
0
votes
1 answer

finding real life names and csh login shell

When I awk the etc/passwd file for real life names how do I single out the csh shell logins: awk -F":" ' {print $5} /etc/passwd I need to find the users that have the csh login shell
user2358660
  • 65
  • 1
  • 3
0
votes
3 answers

Script variables in C-shell

There is a my_grep script #!/bin/csh cat $1 | grep -i -E " a | b " How come cat a* | grep -i -E " a | b " > out1.txt and my_grep a* > out2.txt yield different results?
Evgeny
  • 2,121
  • 1
  • 20
  • 31
0
votes
1 answer

AWK invoking sh instead of csh

I'm sure there is a much easier way to do this, so I'm all ears. sort -nrk 7 my_list.tsv | tail -n 1 | awk '{print("setenv INPUT_DIR `pwd`/"$1)}' The first item in my .tsv are filenames (sorted) that I'm trying to set as an environmental variable…
jwillis0720
  • 4,329
  • 8
  • 41
  • 74
0
votes
1 answer

How to read the first (and only) line of a file, split it into separate strings and append it to variables using csh?

I need some help with the following problem. I just can't figure it out (and yes I did the googlework etc). Using csh I need to read one line from a file (there is only 1 line in the file), split it into separate strings (!not every value is…
skelter15
  • 3
  • 2
0
votes
2 answers

CShell word replacement

I have a short text file with the following syntax: FileName: some name Version: 3 Length: 45 hello, this is an irrelevant, unimportant text. So is this line. Now, I'm trying to write a script that replace the version number with a given new…
Udi
  • 1,080
  • 1
  • 12
  • 25
0
votes
1 answer

How to exit calling script in csh?

I have a csh script (a.csh) which calls another (./b.csh). How do I exit from a.csh if some condition is not satisfied while running b.csh? Here is how I call b.csh b.csh >&! b.csh.log There is a related question for bash How to exit all the…
user13107
  • 3,239
  • 4
  • 34
  • 54
0
votes
4 answers

How to check what shell is running?

I need to check if the script is running from bash or csh. #!/bin/csh if ( `echo $SHELL` != '/bin/tcsh' ) echo 'Please run it in csh' exit endif This code is giving bash: g.csh: line 7: syntax error: unexpected end of file
Ashot
  • 10,807
  • 14
  • 66
  • 117
0
votes
1 answer

Checking the value in the argument passed to a function

When i try to log the argument i get the right value . How do i compare if an argument is a particular string in csh script. And what is the corresponding code in bash. checkstatus() { /bin/echo $1 >> outfile.txt if ["$1" = "show"] then …
Access Denied
  • 224
  • 1
  • 14
0
votes
2 answers

csh list of commands like ksh { list; }

In bourne-compatible shells, the { list; } syntax causes the complete list of commands to be read by the shell before executing it, without opening a new shell. Is there anything similar for the csh? Thanks.
andreas buykx
  • 12,608
  • 10
  • 62
  • 76
0
votes
1 answer

Quoting a string for csh

For the purposes of this question, by "csh", I mean tcsh. I am aware of the standard advice to avoid csh for programming. However, sometimes ones needs to interact with existing csh code, and then it may be necessary to quote a string for csh. To…
Croad Langshan
  • 2,646
  • 3
  • 24
  • 37
0
votes
4 answers

How to get numeric value from a string in csh

I am writing a csh script and need to assign the numerical value in a string to a variable Here is an example of the string value: "pkt_size=78" The characters in the string will always be the same except for the number. I pretty much need to…
user1526912
  • 15,818
  • 14
  • 57
  • 92
0
votes
1 answer

How to join variables in csh script

I am trying to concatenate two variables in a csh script Here is part of the script #!/bin/csh -f set encname = _11111k_1920x1080_x264_5200_quicktime_128.mp4 set lowerisrc = `echo $isrc | tr "[:upper:]" "[:lower:]"` echo…
user1526912
  • 15,818
  • 14
  • 57
  • 92