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
0
votes
2answers
42 views

How to split and access fields delimited by colon?

This piece of code: foreach line (`cat /etc/group`) echo $line end returns line containing 4 fields delimited by :. How to split fields and access the first field of each line?
0
votes
1answer
25 views

Accessing a field in csh

This piece of code: foreach mod ("`lsmod`") echo $mod end outputs each line of lsmod. How can I access the first field, i.e. Module, from each line? Is there any IDE forcsh or extension for vs ...
0
votes
1answer
1k views

How to execute an alias, encapsulated in another source file?

For instance ~/.cshrc: alias job_start 'cd $PROJ_DIR && source .env/bin/activate.csh && rehash && job_run' $PROJ_DIR/.env/bin/activate.csh: alias job_run '(cd $PROJ_DIR/...
1
vote
1answer
41 views

how to do case switch statement in csh

In sh, I know I can do something like the following... #!/sbin/sh case "$1" in 'foo') /path/to/foo.sh ;; 'bar') /path/to/bar.sh ;; *) echo $"Usage: $0 {foo|bar}" exit 1 ;; esac I've searched the ...
0
votes
1answer
28 views

csh: Changing path in non-interactive login

I want this: $ ssh nopathcsh@lo 'echo $path' /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games To return this: /usr/bin /bin I have tried changing and ...
1
vote
2answers
52 views

Why is SHELL pointed to /bin/sh in a Csh script?

Yes, I know C-shell is bad. No, I did not choose C-shell. Yes, I would prefer to use a proper shell. No, I cannot switch to a better shell. I have a very simplistic script: /tmp/env_test.csh #!/...
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="...
0
votes
1answer
1k views

read each line one at a time in csh

In bash, code like this will read each line in a file one at a time: while IFS=$'\r' read -r line || [[ -n "$line" ]]; do something done < "to-read-file" When the code is running, as long as ...
0
votes
1answer
59 views

What does an '@' character mean in a csh script

I'm translating a csh script to bash an came across a line that looks like @ lines = `grep num_lines ../config.txt | awk '{printf("%d",int($2))}' ` What does the '@' do here? I found some ...
0
votes
1answer
51 views

error while using sed in tcsh alias

I am unable to "source/run" my tcsh alias, which is as below: alias inp1 "grep -i "final_model" /scr/cb2TempProd/tmp/$USER/\!:1/Simulation/Input/assemble.preprocessing | sed 's#.*<##; s/>$//'" ...
1
vote
2answers
39 views

Why can't tcsh do a single-line 'which -> vim' command?

I often have to do which command, and then open it in vim to actually see what's inside. I'd like to have an alias or function that does this, with tab completion. Here's what I've tried: superwhich()...
0
votes
1answer
77 views

How to customize .cshrc to configure command prompt?

Background Inspired by this question, I wanted to try to change my command prompt in this manner Enter this line into ~/.cshrc a. setenv PS1 "\[\e[32m\][\[\e[m\]\[\e[31m\]\u\[\e[m\]\[\e[33m\]@\[\e[...
0
votes
0answers
34 views

Add trailing slash in csh

How do I get csh to add a trailing slash at the end of tab autocompletion? eg: \stuff \otherstuff now if I type cd s and press tab, I get: \stuff and not \stuff\
0
votes
2answers
69 views

Comparing 2 files using awk , not getting any results - C shell

I am using c shell and trying to compare 2 files using awk . But the below awk statement doesnt give any result. Need to acheive this solution in awk using C shell. awk 'FNR==NR{a[$0]++;next} { {...
0
votes
1answer
47 views

Ambiguous error while executing ksh file

I have created a audit.ksh file which is used to clear old "*.aud" files. But when i run this file am getting below error. The strange thing is the commands inside the file works fine while executing ...
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 ...
1
vote
2answers
646 views

Use of find in unix on strange file/directory names

I'm writing a script which uses find for putting path of directories this is the part of the script: set list = (`find $PATH -type d`) It works fine until the file or directory names aren't named ...
0
votes
2answers
83 views

How to retrieve prompt format string in csh / tcsh

My current prompt format string is generated by an outside script that is provided by the organization. I want to manipulate it a bit (add time to the string) for that I need my current format string. ...
0
votes
0answers
50 views

How to execute unix command after few background jobs?

My c-shell code has to complete few concurrent background jobs before execution of some unix commands. However, somehow in code my background jobs never returns handle to unix commands. i.e. $cmd1 | ...
-1
votes
1answer
55 views

How to check every file in directory and ask the user to do action in csh shell

The actions I would like to do with this script is to Read the name (without base) of each file in a directory For each file, ask the user if he wants to perform an action (e.g. move the file in a ...
1
vote
2answers
970 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 "...
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 $...
1
vote
0answers
168 views

CSH - if: Expression syntax error [duplicate]

There's this daemon with, for ex. 5 types in one script. Now, i want to be able to start/stop it by specifying the number of the daemon(to start one by one), OR specify "all" (to start in bulk). The ...
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 ...
1
vote
1answer
1k views

Adding corresponding elements from two arrays into new array using csh shell?

I want to use a csh script to merge corresponding elements of two arrays into another array. My script gives error as:- arrayfinal[1]: No match. the results is 0 0 0 0 0 my script is #!/bin/csh ...
1
vote
0answers
66 views

Linking issues with leptonica and libpng

Working through an install of tesseract without sudo permissions and without a standard bevy of prebuilt libraries. The installation I've got to go through as far as I know follows the path of zlib -> ...
0
votes
1answer
4k views

C Shell Argument If Else Loop

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 more arguments." For some ...
1
vote
1answer
169 views

How do I cd and then ls in my cshrc

I want to be able to cd into a path and have it ls automatically. I have tried doing a function such as cs() { cd "@a" ; ls} but this results in an error saying "badly placed ()" so I do not think I ...
-2
votes
1answer
90 views

Linux (shell script) csh

I have a code that contain this line: set file = "" #empty what does it mean?
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/...
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?
0
votes
1answer
400 views

C-Shell : variable in variable

I want the value of variabe ${var}_err_num, but i can't do it. #!/bin/csh -f set list = "book bus apple" foeach var $list set err_num * * @err_num = $err_num + 1 set ${var}_err_num = $...
0
votes
1answer
3k views

How to change Bash to csh with username and password

I want to change bash to csh I'm using following command which is not working chsh -s /bin/csh insite(user) insite(password). I need to write shell script with this command this is the output i got ...
0
votes
1answer
4k views

CSH - How to check if input is NOT number

Need to apply it on csh. to check if the inputted $2 is not number nor the word "all" if ($#argv == 2 && ($2 != all && $2 != **any number**)) then echo "wrong parameter"
0
votes
3answers
63 views

CentOS and Switching Unix Shells

I am using a VMWare Virtual Machine with CentOS installed. I am using BASH shell now but need to run an application that requires C Shell. Can a person just switch shells ? Will you need to ...
0
votes
1answer
43 views

umask does not have -S option

I'm trying to use umask -S to show the current mask in symbolic form (per man umask on my system, which gives me the page BASH_BUILTINS(1)). But umask doesn't seem to behave as the manpage claims: ...
1
vote
0answers
173 views

Convert date in this format to second [closed]

I need to determine when was the last login time from some login times i have. So! I have the date in this format : month as in Oct Sep Jan etc. then follows the day in numeric form 22, 23, 1... and ...
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
1answer
435 views

OpenBSD - How does one set an alias?

I am running the latest OpenBSD and I cannot figure out how to set a simple alias, something along the lines of cls=clear. I've tried putting it in ~/.cshrc and in ~/.profile. I've tried: alias cls ...
0
votes
1answer
18 views

make ${m} ARCH=${ARCH} >&! Make_${m}

In this command (C shell script) make ${m} ARCH=${ARCH} >&! Make_${m} what does >&! mean?
1
vote
1answer
88 views

Program installation: Csh to Bash

I am trying to install xscore v1.3 (XSCORE MANUAL). They provide instructions to set up some environmental variables in the .cshrc file under C-shell. setenv XTOOL_HOME ...
0
votes
1answer
203 views

for loop logic porting from bash to csh

I have below code snippet working in bash: for i in `ps -eaf | grep -i <pattern> | awk '{print $3}'`; do kill -9 $i; done But I have a requirement to port this code to work in csh shell due to ...
1
vote
1answer
216 views

FreeBSD: Is the default user shell `tcsh`?

I was recently reading a tutorial for tcsh and it said that the default user shell for FreeBSD was tcsh and I was surprised. For FreeBSD, is the default user shell tcsh?
-1
votes
2answers
493 views

csh if statement interactive use

Either there's something fishy with my Solaris 10 csh implementation of if statement or I don't get something right (of course the second is very well probable in my case at least) but when I do: % ...
0
votes
2answers
152 views

Run command from history with parameters

Whenever I need to type a long command I find that the exclamation mark to refer to history very handy. For example, !ssh can be used to invoke the last ssh command I used. However I cannot get it to ...
0
votes
3answers
2k views

How to change timezone in current shell session in Redhat

ls -lt shows time in PDT, I want to change it to Asia/Singapore in the current session. I tried set TZ=Asia/Singapore But it's showing the same time on ls -lt. How to do it?
-2
votes
1answer
115 views

Why will “0.0u 0.0s 0:00.00 0.0% 0+0k 0+0io 0pf+0w” display on screen in csh [closed]

friends, I don't know why "0.0u 0.0s 0:00.00 0.0% 0+0k 0+0io 0pf+0w" (and many lines like this) will display when I run some C shell script, but not when some others run. And I never encountered with ...
2
votes
1answer
3k views

syntax error: unexpected end of file

#!/bin/csh -f set no=1460 while ("$no">0) if [$no>900]; then set m=3 else if ["$no">450 && "$no"<901]; then set m=2 else set m=1 fi mv *$no.bin test/abc-$m-$no.bin set no =$no-...
1
vote
1answer
5k views

FreeBSD csh, TAB to show available choices?

How can i configure csh or tcsh to show available choices by pressing Tab twice, just like bash?
1
vote
1answer
3k views

Simple if command not working in csh script

Problem is that when I execute this script using source overspeed (after giving myself execute permission), it asks me "How fast are you going?" as what I set but after I enter any value it gives an ...