Questions tagged [csh]

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.

Filter by
Sorted by
Tagged with
185
votes
3answers
166k views

Difference between 2>&-, 2>/dev/null, |&, &>/dev/null and >/dev/null 2>&1

Just looking for the difference between 2>&- 2>/dev/null |& &>/dev/null >/dev/null 2>&1 and their portability with non-Bourne shells like tcsh, mksh, etc.
25
votes
3answers
3k views

How does a shell know home(s)?

Each shell has an environment variable $HOME set (ex: /Users/lotolo). If I'm under csh I can unsetenv HOME and still if I do cd I'll be in my home. I've tested this also on bash (unset HOME) and it'...
25
votes
2answers
10k 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 ...
13
votes
3answers
7k views

Is it possible to redefine the tilde ('~', home directory)?

Is it possible to redefine the home directory? e.g. to /ext1/username instead of /home/username, i.e. expanding the ~ to another directory (as opposed to changing the actual home directory where users'...
10
votes
3answers
27k views

stderr redirection not working in csh

I run the following command: pkg_add emacs-23.4,2.tbz 2> output.log The output still displays in the terminal. When I press ↑, I get pkg_add emacs-23.4,2.tbz 2 > output.log with a space ...
7
votes
3answers
174 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 ...
6
votes
6answers
3k views

How do I specify arguments to return all dot files, but not . and ..?

Normally dot files are not included for wildcard expansion: % echo * Applications Desktop Documents Downloads Library Movies Music Pictures Public bin If I explicitly ask for dot files, I get them: ...
6
votes
2answers
8k 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 ...
5
votes
2answers
4k views

Convert arg to uppercase to pass as variable

Is there a way to convert the command line argument to uppercase and pass it as a variable within the script being invoked? Eg. ./deploy_app.csh 1.2.3.4 middleware should convert middleware to ...
5
votes
2answers
3k views

Can a home directory have both .cshrc and .bashrc files?

Or are they both not allowed at the same time?
5
votes
2answers
1k views

Show every installed command-line shell?

How to show every installed command-line shell, (i.e. bash, zsh, etc.), with no duplicates, and nothing else, (i.e. no programs that aren't shells)? This code almost works on my Lubuntu system, (...
5
votes
2answers
19k views

How to debug csh scripts?

My lab uses csh scripts to run jobs. It is usually difficult for me to debug a shell script, so I'm wondering if there is a csh debugger I can use. I know there are some flags like -x or -v that can ...
4
votes
2answers
843 views

Find unique values from find

I want to find unique files inside a directory, which also have sub directories. There are specific types of files, say .lib files. There are same .lib file inside different sub directoris. I need ...
4
votes
4answers
13k views

sed command to replace a blank line with two lines of content

How do I replace the first blank line with two lines of content? I did see a question on replacing multiple blank lines with a single blank line in vim sed but don't quite see how to adapt that. So, ...
4
votes
4answers
668 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)
4
votes
1answer
713 views

Which is the real PATH variable

On my office computer it seems like I've have two PATH variables. $path : This is delimited by " " (Space) $PATH : This is delimited by ":" (Colon) Though when I update one, the other one ...
4
votes
1answer
404 views

What's special about “!xxx%s%s%s%s%s%s%s%s”?

I was linked to The Unix-Haters Handbook and stumbled on (page 149): Subject: Relevant Unix bug October 11, 1991 Fellow W4115x students— While we’re on the subject of activation ...
4
votes
3answers
3k views

Preventing duplicate entried in PATH (.cshrc)

I need to prepend directories to the path variable in my .cshrc file and I want to make sure that the entries are not repeated when compared to existing directories in the path variable. Can someone ...
4
votes
2answers
6k views

How to enable double tab autocompletion list in csh?

I've worked in Linux before where when I press tab it autocompletes until it becomes ambiguous. If I pressed tab twice at that point it would give me a list of all possible completions. My current ...
4
votes
1answer
4k views

Is there a csh to bash script translator?

Programming in C shell is considered harmful by some people, but csh scripts are continued to be written by some hardcore csh fans. Is there a free/open source converter to translate csh script into ...
3
votes
3answers
3k views

Error “syntax error near unexpected token `('?”

What's in my terminal bash: settings64.csh: line 35: syntax error near unexpected token `(' bash: settings64.csh: line 35: `foreach i ( $xlnxInstLocList )' Portion of the script set xlnxInstLocList=...
3
votes
5answers
2k views

dircolors “missing second token”

I'd like to customize the colors of ls and as far as I understand the way to go is with dircolors. I did: dircolors > ~/.dircolors Immediately after this I launch a terminal and get this error: ...
3
votes
5answers
4k views

Does $SHELL store the path to the default shell in Linux?

My administrator says that my default shell is set to bash, but $ echo $SHELL /bin/csh $ Is the default shell related to the SHELL variable at all? Is not, what is the variable used for?
3
votes
1answer
2k 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 "...
3
votes
1answer
2k views

How can I clear portion of what is typed into the prompt while working on Linux and using C-shell?

I am working in Linux and C-shell. Often times I would require to change some portion of what is there already in the prompt that I obtain from reverse searching through the history command by use of ...
3
votes
1answer
8k 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 ...
3
votes
1answer
10k views

C Shell script condition for if string contains a newline character

I'm not sure how to express this using the csh string matching syntax. I want to test whether a csh variable contains a newline. I'm basically looking for: if ($mystr !~ <pattern for strings which ...
3
votes
2answers
1k 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 { ...
3
votes
1answer
1k views

How to use ! in the sed command?

Apologize if you feel this question very basic. Anyways, I am typing sed '/[iI]t/ a\\ Found it!' data but it says the error event not found. I tried escaping that ! with backslash \! but it doesn'...
3
votes
2answers
3k views

setting variables inside subshell when using <<

I am using the following method in order to pass commands into a subshell that is started by "newgrp". #!/bin/csh echo "Before newgrp" /usr/bin/newgrp users <<EONG echo "hello from within ...
3
votes
2answers
12k 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 /usr/bin/...
3
votes
1answer
9k views

Changing text color in c-shell

I can change the text color in the terminal permanently by adding this: export PS1="\e[0;31m[\u@\h \W]\$ \e[m" to the .bashrc file. Now I have to go into cshell, what is the corresponding way?
3
votes
1answer
2k views

Error converting a bash function to a csh alias

I am writing a csh alias so that I can use the following bash function in my csh : function up( ) { LIMIT=$1 P=$PWD for ((i=1; i <= LIMIT; i++)) do P=$P/.. done cd $...
3
votes
2answers
212 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 ...
3
votes
1answer
681 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 ...
3
votes
1answer
38 views

How to use here document or assign multiline string to variable in csh?

I want to assign to variable to a multi-line string that contains a variable and then echo it. I attempted using here-doc as shown below. What is the best way to achieve this in csh? set my_name="...
2
votes
1answer
2k views

What's wrong with this csh file?

I don't have any experience writing .sh files. I want to run the pvm2raw utility of this app from the Volume Library. I get the following error when running build.sh in Ubuntu 10.10. build.sh is as ...
2
votes
2answers
5k views

Alias Loop in csh

Why is there an Alias loop error created here: alias df 'printf "\n"; df -hP | column -t' But not here: alias df 'df -hP | column -t' I realize I could call the alias something else and still have ...
2
votes
4answers
5k views

/bin/ls: Argument list too long

I am a biology person and running a program named autodock. I have some files from ZINC library in .mol2 format. As per requirement I need to split this files with the csplit command and I received ...
2
votes
3answers
6k 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?
2
votes
3answers
726 views

How do I make pasted shell commands invisible?

I'm using an AutoHotkey macro to run some shell commands, i.e. ^`:: SendInput set c=".cshrc-acheong"{ENTER} SendInput set v=".vimrc-acheong"{ENTER} SendInput foreach d ( /home/acheong /home/tcama /...
2
votes
3answers
4k views

Convert value from scientific notation to decimal in shell?

How to convert value from scientific notation to decimal in shell? (preferred C shell) Also I'd want to convert it from e-12 to e-9 and then shell 42.53e-12 to 0.04253. I have to do this for a list.
2
votes
2answers
3k views

Undefined variable

I am trying to use this script: #!/bin/csh foreach SUB (1 2 3 4 5 6 7 8 9 10 11 12 13 14) echo $SUB foreach VISIT (1 2 3 4 5 6 7 8) echo $VISIT grep 'StudyDate' -f /home/...
2
votes
1answer
304 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 form ...
2
votes
3answers
5k views

cshrc execute bashrc within itself?

My school has our Linux accounts using csh/tcsh by default. I, however, have a lot setup on my home bashrc and I'd like to use that at school. BUT there's also some important stuff that happens in our ...
2
votes
2answers
238 views

Setting paths for interactive C-shell

My default shell (on Ubuntu) is bash. However, for a particular programme I need to change to the C-shell. For this I have a .cshrc file set up, however, if I change interactively to the C-shell (I'm ...
2
votes
3answers
19k views

How to use while loop in csh shell command prompt?

I am trying to use while loop in csh shell command prompt in RHEL 7.2 but am getting the below error: $ while true while: Expression Syntax. The same is working in bash shell.
2
votes
2answers
126 views

Run 2 commands in parallel but only wait for one command to finish before starting the next

I have set up a number of processes in the background that need to finish processing before the next process can be started. While I've got this set up, there is one step where 2 programs need to be ...
2
votes
2answers
194 views

bash:Syntax near unexpected error '(' [closed]

I am following a tutorial in computational microbiology: William Lindstrom, Garrett M. Morris, Christoph Weber, and Ruth Huey (2008-01-29). Using AutoDock 4 for Virtual Screening. Scripps Research ...
2
votes
1answer
451 views

Automatically set number in vim without modifying vimrc because of limited permission

I don't have permission to modify vimrc, but I really need to view the line numbers every time. Is there an alternative way to do the following without modifying the vimrc file? :set number Plus, I ...