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
1 answer

csh issue retrieving input from multiple lines

The following script is being run on a HP-UX box that has only csh. #!/bin/csh -fx set todaysDate = `date +%m%d%y-%H:%M` echo -n Paste the email information here: set input = $< set info = `echo $input > jcc.$todaysDate` sed…
sayayinx
  • 21
  • 4
0
votes
1 answer

Awk command not working in csh

Please let me know what is wrong with below code: #!/bin/csh set str = "peanut" set sr = "an" awk 'BEGIN { print index($str,$sr) }' The error is awk: Field is not correct. The source line number is 1.
Programmer
  • 6,565
  • 25
  • 78
  • 125
0
votes
1 answer

Change delimiter for foreach in csh

I have a string as follows : set str = "HELLO SO COMMUNITY| CAN YOU HELP ME" foreach word ($str) echo $word end Presently, this prints HELLO and then SO and then COMMUNITY and so on. I want the delimeter for the printing to be | . SO the output…
Programmer
  • 6,565
  • 25
  • 78
  • 125
0
votes
1 answer

Repetition character not working for grep in csh when put in double quotes

I have posted a question earlier about this but now I understand the problem and thus want to repost. The * character is correctly interpreted in my csh script when not put in double quotes, but when I put it in double quotes, it is not correctly…
Programmer
  • 6,565
  • 25
  • 78
  • 125
0
votes
1 answer

Grep query in C shell script not performing properly

When I run the grep command on the command prompt, the output is correct. However, when I run it as part of a script, I only get partial output. Does anyone know what is wrong with this programme? #!/bin/csh set res = `grep -E "OPEN…
Programmer
  • 6,565
  • 25
  • 78
  • 125
0
votes
2 answers

How to use grep in csh script

Below is a simple csh script I wrote. But the set does not work. Can anyone please help me with the error. #!/bin/csh echo "hello" set ans ='grep -r hello ./' echo ans Tried back quotes still not working: #!/bin/csh echo "hello" set ans =`grep…
Programmer
  • 6,565
  • 25
  • 78
  • 125
0
votes
1 answer

if else statement error checking

I am attempting to error check so that if the file is not an ordinary file it will echo File is not an ordinary file. #!/bin/csh echo Enter file name set filename = $< if(-f $filename)then if(-z $filename)then rm $filename …
Josamoda
  • 77
  • 1
  • 13
0
votes
1 answer

How to print whole array in tcsh

I want to print the whole array in tcsh, because then i want to pipe it to uniq, is there a way to do it in tcsh. i had set array and was printing it: echo "$array" but it ended up with error: Word too long, it works for smaller arrrays, Is there…
Ricsie
  • 319
  • 5
  • 14
0
votes
2 answers

Delete last two lines of stdout using c shell?

I want to create a little animation in the stdout of the terminal using printf. So far I figured out how to replace the last line with #!/bin/csh -f printf "text1" printf "text2" sleep 1 printf "\r replaced text2" How do I replace both…
MichaelScott
  • 387
  • 1
  • 3
  • 21
0
votes
1 answer

csh inline if statements

I'm trying to add a script to check conditions before executing a command in my .cshrc file. This checker script returns 0 if the conditions are insufficient, and 1 otherwise. (I realize this is backwards of convention, but I thought it would be…
tomocafe
  • 1,425
  • 4
  • 20
  • 35
0
votes
1 answer

search for an integer after a particular world in shell scripting

I have an input to unix shell script : -mem some_integer cmd1 cmd2 I want to get the integer value following the word "-mem". also i want to then remove both and append a new string using value of some_integer. my output should be like …
Ruchi
  • 693
  • 3
  • 14
  • 27
0
votes
1 answer

converting for-loops into while-loops

Convert the for-loop in the following script to a while-loop. echo "Enter a number" read n count=0 for((i=1; i <= n; i++)) do echo "Enter a number" read a if((a > 0)) then count=$((count+1)) fi done echo "You entered…
relativeLee
  • 39
  • 2
  • 7
0
votes
1 answer

Can't find out if argument is an integer

i am beginner in writing scripts in csh/tcsh so that's why i need you help. I have to find out if arguments of my script are written correctly on stdin. I have some script for example called 'first_script' that must have arguments in this…
0
votes
1 answer

Sum integers in tcsh/ sum string to integer

I'm new into shell and stuff, and i encountered a problem. I have to count how many lines have the files in a directory together with this i count the line length of each file in for $i: find $i -maxdepth 1 -type f -exec wc -l {} \; | tr -s " " |…
Ricsie
  • 319
  • 5
  • 14
0
votes
2 answers

What does $? mean in a shell if statement?

What is the meaning of the following statement in shell script? if ($?REGRESS) then .... endif from where the given function is taking input from? This is a part of an old script which I am not able to understand.
nailed IT
  • 101
  • 2
  • 5