tcsh

How can I check if a variable is empty or not in tcsh Shell?

好久不见. 提交于 2019-12-09 14:20:08
问题 IF I have to check that if a variable is empty or not for that in bash shell i can check with the following script: if [ -z "$1" ] then echo "variable is empty" else echo "variable contains $1" fi But I need to convert it into tcsh shell. 回答1: The standard warnings regarding use of tcsh / csh apply, but here's the translation: if ( "$1" == "" ) then # parentheses not strictly needed in this simple case echo "variable is empty" else echo "variable contains $1" endif Note, though, that if you

Shell 高级编程

試著忘記壹切 提交于 2019-12-09 11:23:38
Shell 高级编程 原创 2016-11-04 景峯 Netkiller Shell 高级编程 http://netkiller.github.io/journal/shell.html Mr. Neo Chen (陈景峯), netkiller, BG7NYT 中国广东省深圳市龙华新区民治街道溪山美地 518131 +86 13113668890 <netkiller@msn.com> $Id: shell.xml 449 2012-08-10 10:38:08Z netkiller 版权声明 转载请与作者联系,转载时请务必标明文章原始出处和作者信息及本声明。 Shell 更多是被看成一种批处理命令,确实很多是是吧 Shell当成批处理去使用的。 我确不这么看,我认为要想开发程序一样去写Shell,把Shell当成一种语言。 我们需要将很多软件开发技巧应用在Shell领域 目录 1. 递归调用 2. 实现守护进程 3. 进程间通信 4. 1. 递归调用 不懂递归不算是合格的程序员 递归调用是一种特殊的嵌套调用,是一个函数在它的函数体内调用它自身称为递归调用。这种函数称为递归函数。 #!/bin/bash ######################################## # Author: Neo <netiller@msn.com> # Home : http:

stderr redirection methods

a 夏天 提交于 2019-12-08 12:39:50
问题 I am running tcsh/csh shell on my machine. lately i have realized my stderr file redirection is not working. Please find the terminal logs as below: >echo b c >>& log >cat log b c >echo $a b c >>& log a: Undefined variable. >cat log b c I have never faced such issues, hence not sure how to debug or troubleshoot. Please advice! An alterate method of redirection is using tee. While I use >& or >>& , i am altogether blocking any output to be displayed on terminal. Is there a way I can do both,

How to run regression using makefile

泪湿孤枕 提交于 2019-12-08 11:54:36
问题 I have tcsh shell. I want to compile once which is VCS and then run multiple testcases using SIMV . Earlier for single test VCS = vcs -sverilog -timescale=1ns/1ps \ +acc +vpi .. and SIMV = ./simv +UVM_VERBOSITY=$(UVM_VERBOSITY) +UVM_TESTNAME=$(TESTNAME) ${vcs_waves_cmd} -l $(TESTNAME).log were defined as constants. I have to replace $(TESTNAME) by looping on an array.I tried as below by switching to bash but ultimately it is causing other failures such as make clean not working. TESTS = ext

sed: replace spaces within quotes with underscores

懵懂的女人 提交于 2019-12-07 15:03:37
问题 I have input (for example, from ifconfig run0 scan on OpenBSD) that has some fields that are separated by spaces, but some of the fields themselves contain spaces (luckily, such fields that contain spaces are always enclosed in quotes). I need to distinguish between the spaces within the quotes, and the separator spaces. The idea is to replace spaces within quotes with underscores. Sample data: %cat /tmp/ifconfig_scan | fgrep nwid | cut -f3 nwid Websense chan 6 bssid 00:22:7f:xx:xx:xx 59dB

Tcsh script does not exit

[亡魂溺海] 提交于 2019-12-07 07:16:42
问题 I am running CentOS 7, and I am having problems with tcsh scripts. I have a simple script called quittest. #!/bin/tcsh echo "Simple Test" exit 0 When I run quittest from the terminal, I get "Simple Test" And it does not exit. I can Control+C to exit. I check on the status of this with: ps aux and it shows quittest with a state of S+ (foreground interruptible sleep). If I change this script to bash, or sh, it runs fine, and exits as expected. I cannot just switch to another shell, because my

minimal typing command line calculator - tcsh vs bash

自闭症网瘾萝莉.ら 提交于 2019-12-07 06:40:02
问题 I like to have a command-line calculator handy. The requirements are: Support all the basic arithmetic operators: +, -, /, *, ^ for exponentiation, plus parentheses for grouping. Require minimal typing, I don't want to have to call a program interact with it then asking it to exit. Ideally only one character and a space in addition to the expression itself should be entered into the command line. It should know how to ignore commas and dollar (or other currency symbols) in numbers to allow me

How to run a tcsh shell command and selectively ignore the status?

隐身守侯 提交于 2019-12-07 05:58:29
问题 I've got a tcsh shell script that I would like to stop with an error on nonzero status most of the time, but in some cases I want to ignore it. For example: #!/bin/tcsh -vxef cp file/that/might/not/exist . #Want to ignore this status cp file/that/might/not/exist . ; echo "this doesn't work" cp file/that/must/exist . #Want to stop if this status is nonzero 回答1: I don't know about tcsh, but with bash, you can use set -e to do this. When the -e flag is set, bash will exit immediately if any

Shared Libraries in Same Folder with App in TCSH

耗尽温柔 提交于 2019-12-06 13:41:34
问题 I am deploying a locally-compiled app to a remote Linux server. Since I don't have root account I cannot put needed shared libraries to /usr/lib Is there a way to overcome this? I put libraries in same folder and changed "path" variable but did not work. 回答1: Two simple options. You can set the LD_LIBRARY_PATH variable inside your script (see Section 3.3.1. of the shared libraries HOWTO). There are problems with this approach for production code, but if set in a wrapper script is probably ok.

How can I bindkey ctrl-left to word-left?

我是研究僧i 提交于 2019-12-05 17:39:56
I use tcsh and emacs. In emacs, I'm used to the ctrl-left bindkey moving me left by a word. I'd like to do the same thing in my tcsh terminal. I can do ctrl-b, but I'm just not used to it. It's not clear to me from the bindkey manpath how to specify the ctrl-left key combination. How do I do it? Google answers all (if you look deep enough). bindkey '^[[1;5D' backward-word # ctrl+left bindkey '^[[1;5C' forward-word # ctrl+right From Google's cache of http://lofotenmoose.info/bsd/conf/amd64/tcshrc-root . This works for tcsh 6.13.00 来源: https://stackoverflow.com/questions/1099507/how-can-i