The C shell (csh), once one of the two major Unix shells with the Bourne shell. Csh had more advanced interactive feature but has been surpassed by modern Bourne-style shells such as zsh and bash.

learn more… | top users | synonyms

1
vote
2answers
23 views

How do I create a rule for custom flag replacement with C shell?

I want to have the following behavior with grep: grep --java <rest of the command> Where --java would either dynamically convert to --include=*.java or internally be equivalent to it. Is ...
2
votes
1answer
83 views

What kind of redirection is >>&?

I'm looking at a cron file that has the following line: 35 0 * * * /bin/csh -c "/home/abc/.cshrc;/home/abc/appTools/bin/xxx.pl >>& /home/abc/appTools/log/xxx.cronlog" Is this another ...
1
vote
0answers
28 views

Read and write line from .txt, in CSH script [closed]

well I have to do a basic script,is mandatory in csh, and I decided to do a simple "task manager". Based on a .txt file, the user can add task, show tasks, delete X task. The problem I don't manage to ...
1
vote
1answer
59 views

Unwanted question mark appended to directory name when using mkdir

I am unsure why when I use mkdir -p $fbase an unwanted ? is appended to the name of the directory (27obs87St01Rec1?) . I have followed similar threads and ran cat -A filename to see if there are ...
1
vote
0answers
20 views

Piping to 'tee' commands prevents changes in environment variables

I have a csh script using which I modify certain environment variables and echo values of these environment variables from within this script. I source this from another script: source ...
1
vote
0answers
36 views

Setting environment variable using shell script

I am using csh scripts for some automation purpose. I have a number of scripts, and the beginning of all of which I need to set a fixed set of environment variables. |----SCRIPT 1---| |----SCRIPT ...
1
vote
1answer
21 views

cshell alias: How to use nested single quotes(') in in cshell alias

I am trying below alias in cshell: alias sll 'ls -l \!* | grep -oE '[^ ]+$' | paste -s | xargs ls -l' For this CSH says, Illegal variable name. If I use \$, alias will be set without any error. ...
3
votes
1answer
191 views

Odd alias “find . -name '*\!{*}*' -ls” in Unix Power Tools

From Unix Power Tools 3rd Edition page 175: Article 9.27 shows a way to match directories in the middle of a path. Here's a simpler "find file" alias that can come in very handy: alias ff ...
2
votes
0answers
29 views

unix c-shell : disk checking

im totally new in shell scripting. I have task to simplify an old c shell script. Basically, the script have 10 devices that using hp-ux and i want to check the disk space in each devices. my ...
1
vote
1answer
47 views

C Shell Script syntax error “unexpected end of of file”

I am trying to write a c-shell script that checks for number of arguments and echos a string, but I am getting an unexpected end of file syntax error and I don't understand why. Here is what I tried: ...
0
votes
0answers
24 views

Unix -untar files only looping one time - C-shell

I have list of *.tar.gz files that I want to unzip and untar at once. The code: foreach summ (`ls *.tar.gz`) gunzip -d < $summ | tar xf - end But only one file has been untarred. How would ...
1
vote
2answers
44 views

Merging two files using scripts

I am trying to merge two files of different lengths using a script. I want the longer file to be appended to the end of the shorter file and when both files are of equal length they are suppose to ...
0
votes
0answers
19 views

Escape special chars in csh alias

I want to create an alias for the following thing: diff -r <dir1> <dir2>| grep diff | grep -v "Files " | grep -v "\.git" \ | awk '{print "tkdiff " $3 " " $4}' I am getting lost with ...
0
votes
0answers
38 views

Help me with C-shell Script: Disk checking

i am new in shell script. i have given a task to make a C-shell script. I have list of ip address and device name respectively. For example; cal 1 : 100.21.25.10 cal 2 : 100.21.25.11 cal 3 : ...
1
vote
1answer
24 views

Alias gedit to accept an argument

This alias works in UNIX and in Redhat. It does not work in Fedora alias te 'gedit "\!*" &' Usage: te myfile.cpp It opens gedit with myfile.cpp in the edit window and runs in the ...
0
votes
0answers
72 views

why are directories which are empty not removed after rmdir?

foreach file (`find . | awk -F/ 'NF == 3'`) echo $file set olddir = `echo $file| cut -f 1-3 -d '/'` echo $olddir set newdir = `echo $olddir | cut -c 1-2,5-` echo $newdir mkdir -p $newdir ...
1
vote
3answers
59 views

csh: Using -d as an argument and not test

I know that -d /path/to/dir can be used to test command for checking a directory. Then: if ( $argv[1] == "-d" ) does not work because of that. However, I need to be able to pass -d as an argument ...
7
votes
3answers
108 views

'switch' based on shell

I would like to source (i.e. not call) a script from any shell (bash/csh are the primary targets, but fish, zsh, ksh, and rc would also be interesting). I would like if the script can be a single ...
1
vote
2answers
89 views

how to do inverse cut?

I am sill new in this. I would like to ask, how to inverse the cut? Example; ./24feb/frfr I want after cut command, the result will be ./feb/frfr. How to do it?
-1
votes
1answer
36 views

Avoid pgrep in csh

I got that code foreach pr (`pgrep "$NAME"`) And I try to avoid pgrep: foreach pr (`grep "$NAME" | awk '{$2}'`) but that does not really work. (later with that pr should be the PID printed out ...
0
votes
2answers
253 views

Bourne Shell to CShell

This works fine: #!/bin/sh ALTER="$1" NAME="$2" for pr in $(pgrep $NAME); do elapse=$(ps -o etime= -p $pr) [ "${elapse%:*}" -gt "$ALTER" ] && echo $pr done But if I try to switch ...
1
vote
0answers
79 views

csh: redirecting output from foreach

In csh: How do I redirect the output from a foreach-loop to a pipe? This works but uses a temp file: set tmpfile=/tmp/file ...
1
vote
2answers
69 views

List files in hierarchy of directory

I need to list files in hierarchy of directory. For that I wrote script like foreach file ( * ) ls ${file}/*/*/*/*/*.root > ${file}.txt end But for this I have to know that in the directory ...
0
votes
1answer
44 views

Is there a GUI debugger for csh script?

I have read another question in UNIX & LINUX stack exchange. The GUI provided in that question can be used to bebug *.sh file. How about to debug *.csh file? What other plugins for eclipse can I ...
2
votes
1answer
45 views

csh: Convert aliases into commands that set these

The command alias lists the active aliases. But it does this in a way that is different from how to set the alias: % alias foo 'bar \!*' % alias baz quux xyzzy % alias corge 'grault \ garply (quux ...
1
vote
1answer
320 views

How set environment variable permanently in Red Hat Linux?

As I'm using Red Hat Linux 5.3, I'm unable to set environment variable permanently. I want the file names for csh, from which I can add the environment variables permanently.
1
vote
1answer
44 views

csh array/command substitution with gnu parallel

First of all, yes, locked into csh on a Solaris box, can't do anything about it, sorry. I have a report batch I was running using a foreach loop. Right now it runs as a single thread and I would like ...
0
votes
1answer
113 views

C Shell Argument If Else Loop

I am new to C -Shell programming. I am writing a script that, if one or more arguments are entered after the script, it will display them. if no arguments are entered, it will say "Please enter one or ...
0
votes
0answers
45 views

Adding strings in front of the prompt

I am trying to add an additional string in front of the 'login' names that I usually see in my terminal. Currently, this is what I am seeing, where 'zac' is my user alias and 'titem' is my machine ...
1
vote
0answers
62 views

csh: How to save the shell environment (env, current dir, shell history) in a file and set it on another shell?

I start interactive terminal using farm (LSF). These terminals get opened on some random host and get closed automatically after 15 days. I want to save the current shell environment (env, current ...
0
votes
0answers
76 views

CSH: Determine index number of string in an array

I am using csh. Consider an array of arbitrary length: set array = ( abc def ghi ) I have the following variable set var = "def" How can I find $var in $array and determine its index value? I ...
2
votes
2answers
81 views

Add an application to the command search path in csh

Recently, I have installed an application (gnuplot) under user directory (/home/usr/bin). I want to run the application whenever I type 'gnuplot' in any directory. What could I do? I tried to set the ...
2
votes
1answer
168 views

csh: setting command completion for `cd` to show both directories and files

In my csh terminal, when I do: ls tab -- it shows everything in the current directory as a possibility cd tab -- it shows only directories in the current directory as a possibility. If no ...
1
vote
0answers
24 views

How to install iwidgets without root access and set the enviornment

Recently, I want to run a script(PWgui) which requires Tcl (Itk). The manual suggests that I have to install iwidgets4 beforehand. I am using the university cluster and don't have any root privileges. ...
0
votes
1answer
151 views

csh: Terminal inherits environment variables from an unknown location

I'm on a shared machine running CentOS 5.10 that I log onto using VNC from Windows 7. Our default and official shell is csh. Every time I open a new terminal, I have three particular environment ...
1
vote
1answer
332 views

Read data from a file in a csh script

Is there a way to read data from a csv file into a Cshell script? I have a small script, which calls another script recursively with a set of parameters. I want to read this set of parameters from a ...
5
votes
1answer
480 views

Source Bash automatically in terminal

How can I automatically source a particular bash script when I open a terminal window by right clicking somewhere and choosing "open in terminal"? For example, every time I open a terminal I need to ...
1
vote
2answers
116 views

CSH and all output (with errors) to file

I need save all output from compilation to file. I have many errors "undefined reference" and I want see all of these errors. I try "makeall >& out", but in file "out" aren't any of error ...
2
votes
2answers
961 views

Is it possible to send a HEREDOC over ssh to a remote host from inside a script running locally?

I essentially want to run a script on machine A which will SSH into machine B, execute commands on B, and return the output to machine A. So I am creating a csh script to do this, hopefully, if it's ...
1
vote
2answers
2k views

What do unlimit and limit do in the context of csh?

I'm running a csh script that calls unlimit and limit just before running a scientific model. The script looks something like so (truncated for brevity): #!/bin/csh -f # ... unlimit limit ...
0
votes
1answer
129 views

What does dollar underscore mean in tcsh? $_

In a script I'm debugging, I see it use $_ at the beginning of the file. It appears to suck in the full command that called the file. When trying to wrap this script in another script though, the $_ ...
0
votes
1answer
145 views

How to set the path of the default compiler in ./cshrc

I am using a unix workstation with C shell. There were two compilers of mpif90, one compiled with ifort and one with gfortran, installed on the system. The default mpi compiler was the one compiled ...
-1
votes
1answer
57 views

csh: Get rid of job+PID when forking

With bash I can run: $ ssh bashuser@localhost '( ls -d / nosuchfile ) & echo foo; wait' foo ls: cannot access nosuchfile: No such file or directory / If I try the same with csh I get: $ ssh ...
3
votes
2answers
129 views

Compatibility scripting: Save $? for use later

I would like to write a small part of a script that saves the error status, executes some other code, and sets the error status to the original error status. In Bash it looks like this: << some ...
2
votes
2answers
437 views

Event not found in sed call in csh script

I tried the code as given on delete text between curly brackets however I am facing this different error regarding event in sed. file contains: This is { {the multiline text} file } that wants { ...
0
votes
1answer
116 views

Declaring User-Defined variables in the C shell in UNIX read-only

I'm having trouble finding documentation, but what is the command to make a user defined variable in the c shell read-only in unix?
3
votes
1answer
161 views

parametric aliases in csh to add export command

I'm trying to find a way to translate functions to csh/tcsh aliases, since they lack functions but have parametric aliases. As a first step I'm trying to create an export command. Here's what I've ...
6
votes
1answer
988 views

Are there problems with hyphens in functions, aliases, and executables?

In my testing (in Bash and Z Shell), I saw no problems with defining functions or aliases or executable shell scripts which have hyphens in the name, but I'm not confident that this will be okay in ...
1
vote
2answers
81 views

C Shell: different actions depending on the file type

I very new to C Shell. I am trying to read a file from the command line, and determine whether it's a zip file, a .txt, a symbloic link, a pipe, or whatever ("unknown"). Then I'd like to execute a ...
4
votes
4answers
463 views

Text files containing their own name

I need to find in certain directory and all its' subdirectories all text files that contain their own name. How do I do this? (preferably without awk command)