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
796
votes
29 answers

How to determine the current interactive shell that I'm in (command-line)

How can I determine the current shell I am working on? Would the output of the ps command alone be sufficient? How can this be done in different flavors of Unix?
josh
  • 13,793
  • 12
  • 49
  • 58
558
votes
20 answers

Can a shell script set environment variables of the calling shell?

I'm trying to write a shell script that, when run, will set some environment variables that will stay set in the caller's shell. setenv FOO foo in csh/tcsh, or export FOO=foo in sh/bash only set it during the script's execution. I already know…
Larry Gritz
  • 13,331
  • 5
  • 42
  • 42
362
votes
19 answers

Getting ssh to execute a command in the background on target machine

This is a follow-on question to the How do you use ssh in a shell script? question. If I want to execute a command on the remote machine that runs in the background on that machine, how do I get the ssh command to return? When I try to just…
dagorym
  • 5,695
  • 3
  • 25
  • 23
118
votes
11 answers

Edit shell script while it's running

Can you edit a shell script while it's running and have the changes affect the running script? I'm curious about the specific case of a csh script I have that batch runs a bunch of different build flavors and runs all night. If something occurs to…
ack
  • 14,285
  • 22
  • 55
  • 73
89
votes
7 answers

How to replace a path with another path in sed?

I have a csh script (although I can change languages if it has any relevance) where I have to: sed s/AAA/BBB/ file The problem is that AAA and BBB are paths, and so contain '/'. AAA is fixed, so I can say: sed s/\\\/A\\\/A\\\A/BBB/ file However,…
Brian Postow
  • 11,709
  • 17
  • 81
  • 125
76
votes
6 answers

Redirect stderr to stdout in C shell

When I run the following command in csh, I got nothing, but it works in bash. Is there any equivalent in csh which can redirect the standard error to standard out? somecommand 2>&1
zdd
  • 8,258
  • 8
  • 46
  • 75
55
votes
2 answers

Maximum length of command line argument that can be passed to SQL*Plus?

I am calling SQL*Plus from Linux C Shell: sqlplus username/password @file.sql var1 var2 var3 If I pass a string as var1, how long can this string be? Is it governed by the OS? In this case: Linux version 2.6.9-100.ELsmp…
Umber Ferrule
  • 3,358
  • 6
  • 35
  • 38
53
votes
1 answer

How to set an environment variable for just one command in csh/tcsh

In bash, I can set a temporary environment variable for just one command like this: LD_LIBRARY_PATH=/foo/bar myprogram Can I do something similar in csh / tcsh? I could do setenv LD_LIBRARY_PATH /foo/bar; myprogram; unsetenv LD_LIBRARY_PATH , but…
Tor Klingberg
  • 4,790
  • 6
  • 41
  • 51
47
votes
3 answers

removing new line character from incoming stream using sed

I am new to shell scripting and i am trying to remove new line character from each line using SED. this is what i have done so far : printf "{new\nto\nlinux}" | sed ':a;N;s/\n/ /g' removes only Ist new line character. I somewhere found this command…
nav_jan
  • 2,473
  • 4
  • 24
  • 42
45
votes
4 answers

Setting stacksize in a python script

I am converting a csh script to a python script. The script calls a memory-intensive executable which requires a very large stack, so the csh script sets the stacksize to unlimited: limit stacksize unlimited When I try to reproduce this script in…
marshall.ward
  • 6,758
  • 8
  • 35
  • 50
41
votes
9 answers

How do I get diffs of all the files in a pending Perforce changelist?

I want to get diffs on files in a specific pending changelist. I wish I could do this: p4 diff -c 999 Can someone help me string together some csh magic to make this happen? Maybe take the output of p4 opened -c 999 and piping it to p4 diff?
ack
  • 14,285
  • 22
  • 55
  • 73
38
votes
10 answers

Display only files and folders that are symbolic links in tcsh or bash

Basically I want do the following: ls -l[+someflags] (or by some other means) that will only display files that are symbolic links so the output would look -rw-r--r-- 1 username grp size date-time filename -> somedir -rw-r--r-- 1 username…
vehomzzz
  • 42,832
  • 72
  • 186
  • 216
34
votes
11 answers

Output of last shell command

Not until midway through a 3 hour build script, I'll remember that I want to see something at the beginning of the output after it's done. At this point I've exceeded the number of lines in my terminal so I can't scroll up to see it (or the…
ack
  • 14,285
  • 22
  • 55
  • 73
34
votes
3 answers

How can I check if a variable is empty or not in tcsh Shell?

IF I have to check that if a variable is empty or not for that in bash shell i can check with the following script: if [ -z "$1" ] then echo "variable is empty" else echo "variable contains $1" fi But I need to convert it into tcsh shell.
ramkrishna
  • 632
  • 1
  • 7
  • 24
31
votes
2 answers

csh idioms to check for environment variable existence?

I've got a few csh scripts where I need to check that certain environment variables are set before I start doing stuff, so I do this sort of thing: if ! $?STATE then echo "Need to set STATE" exit 1 endif if ! $?DEST then echo "Need to…
Pete
  • 10,310
  • 7
  • 53
  • 59
1
2 3
78 79