33
votes
Accepted
How does a shell know home(s)?
In the case of csh and tcsh, it records the value of the $HOME variable at the time the shell was started (in its $home variable as noted by @JdeBP).
If you unset it before starting csh, you'll see ...
18
votes
Error "syntax error near unexpected token `('?"
Follow the actual installation instructions properly!
You buried this in a comment:The environment variables are written to settings[32|64].(c)sh at "/opt/Xilinx/14.7/ISE_DS". To launch the Xilinx ...
15
votes
while command not working when bash script is sourced in tcsh?
This error?
$ tcsh
tcsh> source while.sh
i=1: Command not found.
while: Expression Syntax.
tcsh> exit
Csh/tcsh is a different shell than POSIX sh or Bash. Trying to run a script in sh syntax ...
14
votes
Accepted
Convert arg to uppercase to pass as variable
Using bash (4.0+), inside the script:
newvarname=${3^^}
Using tcsh:
set newvarname = $3:u:q
Using zsh:
# tcsh-like syntax:
newvarname=${3:u} # or just $3:u
# native syntax:
newvarname=${(U)3}
...
13
votes
Accepted
Show every installed command-line shell?
On FreeBSD, TrueOS/PC-BSD, DragonFly BSD, et al.
The list of approved shells, i.e. shells that the administrator permits users to change their login shell to with the chsh command, is in the ...
12
votes
Error "syntax error near unexpected token `('?"
bash doesn't have a foreach; this script is probably meant to run in csh or tsch. If you are invoking the script with ./myscript.csh, make sure its first line is #!/bin/csh (or whatever the full path ...
11
votes
Convert value from scientific notation to decimal in shell?
printf will do this for you, from shell.
$ FOO=42.53e-12
$ BAR=$(printf "%.14f" $FOO)
$ echo $BAR
0.00000000004253
$
In ancient+arcane C-shell, this would be.
$ set FOO=42.53e-12
$ set BAR=`...
10
votes
Linux crontab -- which shell am I using
From crontab(5):
Several environment variables are set up automatically by the cron(8)
daemon. SHELL is set to /bin/sh, and LOGNAME and HOME are set from
the /etc/passwd line of ...
10
votes
Accepted
Find unique values from find
With GNU tools:
find . -name '*.lib' -print0 | awk -v RS='\0' -F/ '! seen[$NF]++'
9
votes
Accepted
What's special about "!xxx%s%s%s%s%s%s%s%s"?
I don't feel like digging for the sources of 25-year old shells, but
It could be a format-string vulnerability.
If the shell contains code like
printf(str);
where str is some string taken from the ...
9
votes
Accepted
How to use while loop in csh shell command prompt?
The syntax of while loops in csh is different from that of Bourne-like shells. It's:
while (arithmetic-expression)
body
end
When csh is interactive, for some reason, that end has to appear on its ...
8
votes
Difference between 2>&-, 2>/dev/null, |&, &>/dev/null and >/dev/null 2>&1
Consider this an addendum to the selected answer.
You may want to know which forms are POSIX and which are not.
Two POSIX forms are involved:
2.7.2 Redirecting Output
2.7.6 Duplicating an Output ...
8
votes
Accepted
Introducing a line break into a file having different columns on the basis of text in the value column
$ awk 'NR > 1 && $1 != prev { print "" } { prev = $1 }; 1' pdb_ligands
1aa6 HETATM 4MO A 803
1aa6 HETATM SF4 A 800
1ao0 HETATM 5GP A 467
1ao0 HETATM SF4 B 466
1ao0 HETATM SF4 C ...
7
votes
Accepted
What is the exact difference between a .login and .cshrc file?
The manual describes what files (t)csh loads when it starts. (T)csh always reads .cshrc. .login is only read if the shell is a login shell, i.e. the first program after logging in. When you type your ...
7
votes
How does a shell know home(s)?
So how does the shell know where is my/other_user home?
It doesn't. You're just not performing the experiment properly. As you can see from the C shell manual, the cd command changes to the value ...
6
votes
/bin/ls: Argument list too long
Don’t parse the output of ls.
Just say foreach f (*). Also,
You should always quote your shell variable references
(e.g., "$f") unless you have a good reason not to,
and you’re sure you know what ...
5
votes
ulimit command not found (without sudo) and error - coredumpsize: Can't set limit (Operation not permitted)
ulimit is a sh family (so bash, ksh etc) builtin. For csh family the command is limit. (zsh is complicated and allows both.)
Normal users can not raise their hard limits. Only root can do that. ...
5
votes
Run 2 commands in parallel but only wait for one command to finish before starting the next
prog2 & (prog1 ; prog3) &
5
votes
Accepted
Undefined variable
Aside from all the reasons scripts shouldn't be written in csh, you are mixing bash syntax and csh syntax in your script.
You're starting your loop with the csh foreach and trying to finish them with ...
5
votes
Advanced aliasing for csh shell
Aliases in the csh shell are slightly more advanced than aliases in sh-like shells.
To create an alias n that calls nedit with the given filename and that adds a .txt extension to that filename, you ...
5
votes
Accepted
How to force csh use local bin?
The shell searches the directories in the order that they appear in the PATH environment variable. If there is another command with the same name in one of the other PATH directories, it will pick it ...
5
votes
Accepted
How to check every file in directory and ask the user to do action in csh shell
Part of your shell code looks like bash code even though you use a #!-line specifying csh. csh does not have a read command, and this is why you get a signal 13 error.
Signal 13 is the PIPE signal, ...
5
votes
Program installation: Csh to Bash
To set an environment variable, you must both assign a value to a shell variable and export it. This can be done in one go with
export variable=value
or in two steps with
variable=value
export ...
5
votes
OpenBSD - How does one set an alias?
.cshrc is copied over from /etc/skel because it exists there and that's what happens to the contents of /etc/skel on (most) user account additions. However that's totally unrelated to sh or ksh; ....
5
votes
Accepted
How to use if on csh FreeBSD from test if file is older then X minutes
You state in your comments that you know:
How to install bash.
Not to change the default shell away for root.
Bash does not install into /bin and is hence not available first hand in single user mode....
5
votes
How to reload aliases added in ~/.cshrc without reboot FreeBSD 11.3
You can just run logout and then log in again, no need for full reboot.
As an alternative, simply run csh inside existing shell.
5
votes
Accepted
What does \!^ in csh alias do
Not a csh user myself but this seem to be history control.
!^ gives the first argument of the previous command. This is the same as !:1 . Remember that, just as the ^ (caret) is the beginning-of-line ...
4
votes
Accepted
Automatically set number in vim without modifying vimrc because of limited permission
You could create your own vim configuration file, and then create an alias for vim to use that file instead of .vimrc:
vim .vimrc-cdnszip
Put the following contents into this file:
source /etc/vim/...
4
votes
Accepted
How to use ! in the sed command?
Which OS did you try it on? On HP-UX 8.11 csh there are 2 ways to cancel the speacial meaning of exclamation mark for history substitutions (see History substitutions in man csh).
Put space after ! (...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
csh × 287tcsh × 62
shell-script × 55
shell × 48
bash × 46
alias × 20
linux × 19
scripting × 16
freebsd × 14
environment-variables × 11
sed × 8
find × 8
path × 8
awk × 7
ssh × 7
command-line × 7
io-redirection × 7
wildcards × 7
prompt × 7
zsh × 6
text-processing × 5
files × 5
grep × 5
rhel × 5
autocomplete × 5