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
1
vote
2answers
38 views

csh to get difference been start and end time both inputs in hh:mm:ss format

./script.csh 05:25:00 02:30:50 should return output in mins since i am looping through the series recursively how to compare values with new large value . would | bc work in csh ?
0
votes
0answers
16 views

csh/tcsh Tab Completion with “complete = enhance” Strange Behavior

set complete = enhance is put in .cshrc, and we have two files, test_ab_dd.c and test_abc_dd.c. If I type test_ab_<TAB> in the command line, csh DOES NOT autocomplete to test_ab_dd.c. I have to ...
0
votes
1answer
35 views

file name matching

I have 2 folders with number of files with a pattern of File-1 1234_-_abcdef_abcdefg.abc File-2 1234_-_qwerty_abcdefg.abc My code goes like foreach d (`cat deck_list`) foreach c (`cat cars_list`...
0
votes
1answer
26 views

How to read and replace with two arguments file in Cshell?

I'm trying to make a script what automatically replace a word in the text file. In a.v, BIRA_0 0 BIRA_1 400 BIRA_2 800 BIRA_3 C00 ... in b.v, BIRA_0[25:0] BIRA_0[95:26] BIRA_0[125:96]...
0
votes
1answer
71 views

Validate the user input against a specific pattern BASH

if ($input !~ [[:upper:-]][[:digit:]][[:digit:]][[:digit:-]][[:digit:]][[:digit:]][[:digit:]]) then goto error1 else echo $input endif I have tried the above code to match the pattern "P-70-90" ...
0
votes
0answers
44 views

Find and print permissions command in a csh file

Trying to create a .csh file that can find and display permission of the files in the directory. Using the following content of the script #!/bin/csh -b find . type -f \( -name "*.sh" -o -name "*....
0
votes
0answers
76 views

pipe into if then in csh/tcsh

I would like to have a csh script to test a variable between two pipes. For example (the incoming resembles a json file but without the newlines and indentations): set debug = 1 cat test.inp | if ($...
0
votes
0answers
37 views

Read numbers from a txt file as the variables, each time for each line

I just began learning to write c-shell scripts. (#! /bin/csh) I have a txt file like this. (contain four parameters of three cases) 1 2 3 4 5 6 7 8 9 10 11 12 And I want to read this file each ...
2
votes
3answers
147 views

How can I dynamically change a path in my aliases?

I have a bunch of aliases in my .cshrc file which use the path: /projects/project_name/my_name/$CLIENT I've written a short script which is intended to take a folder name from my working directory ...
0
votes
0answers
28 views

csh: run a command before all terminal commands, but not for commands in sourced files

I'm currently using the csh postcmd alias to run a command before each terminal command is executed. However, I've found that this command also gets executed for every line in a sourced file. For ...
-1
votes
1answer
50 views

Which of the following commands created a bash subshell

Which of the following commands created a bash subshell? bash bsh csh None of the above This question asked in recent exam and i was unable to answer. Can any one give me right ...
1
vote
1answer
148 views

How to use if on csh FreeBSD from test if file is older then X minutes

I have the following code working in Debian system's: for File in "${Files[@]}"; do if test "`find $FolderDownload/$File -cmin -190`" ; then echo "File is new then 3 hours" # Set ...
1
vote
3answers
72 views

How can I give new file names while a program is working in a loop in cshell?

I have lots of .dat file and I want to convert them to .sac file (a type of seismogram file). I convert files with xy2sac program (I didn't write the code), but I have to give converted files a new ...
2
votes
1answer
99 views

What is the use of `!#` in csh, bash, zsh and probably other shells?

From man bash: !# The entire command line typed so far. From man zshall: !# Refer to the current command line typed in so far. The line is treated as if it were complete up to and ...
0
votes
1answer
65 views

override value of $_ in linux csh script

I would like to override value of $_ in linux csh script. I run this script in xterm using cmdline: chmod +x test.csh test.csh test.csh content: #!/usr/bin/tcsh .... source sourceme.rc .... ...
0
votes
1answer
124 views

tcsh: search entire array for a variable

I am modifying a suite of scripts written in tcsh. Unfortunately, these scripts can't be rewritten because the program they interface with is also written in tcsh. I just want to get out of the way ...
2
votes
1answer
161 views

How to make tcsh multiline prompt use newline character?

Scenario I like to use a multi-line prompt. set prompt="${bold}${green}%M${white}:${red}%c5${unbold} \n${white}% " I quite often copy/paste terminal lines into Windows emails. Problem It appears ...
0
votes
2answers
183 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
34 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 ...
1
vote
1answer
2k 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
59 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
185 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
100 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
164 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 ...
1
vote
2answers
54 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
699 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
53 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
83 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
127 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 ...
0
votes
1answer
150 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/>$//'" ...
0
votes
2answers
319 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
59 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
vote
0answers
124 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 -> ...
1
vote
1answer
566 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
165 views

Linux (shell script) csh

I have a code that contain this line: set file = "" #empty what does it mean?
0
votes
1answer
990 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
3answers
156 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
72 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: ...
2
votes
1answer
839 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
509 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
164 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 ...
1
vote
1answer
310 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
1k 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: % ...
-1
votes
1answer
162 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 ...
0
votes
2answers
87 views

Directory tree listing, script does not work in csh?

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' I found a command to display directory tree (see above), it didn't work correctly. It gave error message "...
1
vote
1answer
295 views

user resources csh.login restrictions

I need to fix a vulnerability in a RedHat 6 server: File /etc/csh.login must exist, and must trigger an invocation of source /etc/profile.d/IBMsinit.sh. I verified file csh.login is in /etc, but I ...
-2
votes
1answer
148 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 ...
0
votes
3answers
3k 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?
0
votes
0answers
102 views

cshell text editor

Is there any text editor with highighting for cshell scripts that includes code folding? (Preferable something with a less steep learning curve than vim and emacs) I haven't been able to find ...
1
vote
3answers
486 views

get average for all numbers with irregular columns

all Can Awk deal with irregular columns? i.e. I have a file like below, each columns may have different number of values, how to get the average of all the positive values? Please note, the ...

1
2 3 4 5