tcsh

tcsh scripting, problems with find and special characters in file names or directory names

流过昼夜 提交于 2019-12-23 05:26:11
问题 Im a beginner scripter, writing scripts in tcsh and csh(these are teached in my course) Im 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 arent named such as: @fi@@lename&& or −filename or :−,?!drectoryanem!-`` These special characters i couldnt handle i changed the find script to: set list = ("`find $PATH -type d`") bit none of these works, when i want to use

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

我是研究僧i 提交于 2019-12-22 08:58:20
问题 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? 回答1: 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

How can I find the location of the tcsh shell script I'm executing?

血红的双手。 提交于 2019-12-22 03:45:48
问题 Say I put an executable tcsh file in /path/to/my_script.csh and my current directory is anywhere, for example I'm in /path So I type to/my_script.csh I want to have a line in my_script.csh that will return "/path/to/my_script.csh" - like ruby's __FILE__ 回答1: If you want to ensure the same result (full path and script name) try something like this: ... rootdir=`/bin/dirname $0` # may be relative path rootdir=`cd $rootdir && pwd` # ensure absolute path zero=$rootdir/`/bin/basename $0` echo

Is there a way to make this perl code capture stderr as well as stdout from a tcsh?

て烟熏妆下的殇ゞ 提交于 2019-12-22 00:27:21
问题 open UNIT_TESTER, qq(tcsh -c "gpath $dir/$tsttgt; bin/rununittests"|); while(<UNIT_TESTER>){ reportError($ignore{testabort},$tsttgt,"test problem detected for $tsttgt:$_ ") if /core dumped/; reportError($ignore{testabort},$tsttgt,"test problem detected for $tsttgt:$_ ") if /\[ FAILED \]/; writelog($tsttgt,$_); } close UNIT_TESTER; I have tried to redirect stderr to stdout using this syntax but it didn't work: open UNIT_TESTER, qq(tcsh -c "gpath $dir/$tsttgt; bin/rununittests >& "|); I have

open last modified file in the directory using vi

别说谁变了你拦得住时间么 提交于 2019-12-20 20:30:42
问题 I want a quick way to open the last modified file in the directory, perhaps in a form of alias. Currently, I do ls -ltr. Then copy-and-paste the filename Assume that I am using tcsh 回答1: vi `ls -tr | tail -1` 回答2: Creating an alias for the mentioned answer will avoid typing the command every time. Add below entry in .tcshrc file and reload. alias v='vi `ls -tr | tail -1`' To avoid going to log folder and executing the command, create below alias and reload. alias -- -='cd -' alias v='cd /path

How to color a prompt on FreeBSD/cshrc?

自作多情 提交于 2019-12-20 10:45:07
问题 I'm being put in charge of managing a bunch of servers, I want to set up my prompts on each of them so that I don't get confused as to where I am logged in to. I've edited my .cshrc files and put this in them: set prompt=`whoami`@`hostname -s`:$cwd'$ ' But I'd like to color that prompt so it stands out a bit more. Maybe green with white text or something. How can I do that? I'm not very familiar with the shell syntax. I'm SSH-ing in from the standard terminal that comes with Ubuntu, if that's

Accessing array elements with spaces in TCSH

…衆ロ難τιáo~ 提交于 2019-12-20 07:14:52
问题 I'm trying to create a small little convenience script for our team. Unfortunately, our entire build environment is based on tcsh for historical reasons. In the following script, each element of BUILD_MATRIX is a : delimited pair. I need to separate out each part of this pair for processing, but the array malfunctions for some reason. #!/bin/tcsh set BUILD_MATRIX = ( "makefile.make:make --jobs --makefile=makefile.make" \ "Makefile:make --jobs --makefile=Makefile" \ "build.xml:ant" ) foreach

why is a double-quoted awk command substitution failing in csh

泪湿孤枕 提交于 2019-12-20 05:42:16
问题 Using C shell, the following command-line set pf = "`awk -v var=$pd '{if($1<0) print var, $2, $3}' test.txt`" returns an error in awk: awk: {if( <0) print var, , } syntax error. This is especially puzzling as the command itself works without any problem: awk -v var=$pd '{if($1<0) print var, $2, $3}' test.txt Is there a way that we can store all output of the single Awk command line into a single variable? What is the reason the above is failing? 回答1: After some tinkering, I can only come to

python subprocess.call() “no such file or directory”

守給你的承諾、 提交于 2019-12-19 05:23:07
问题 I've found a few questions on the module but the more common problem seems to be getting the argument list right which I think I have managed (eventually) I am trying to run a program that expects an input like this in the command line, fits2ndf in out with 'in' being the filepath of the file to be converted and 'out' being the path and filename to save the result to. So using Subprocess, subprocess.call(["fits2ndf","/media/tom_hdd/Transfer/reference.fits","/media/tom_hdd/Transfer/reference

How can I use aliased commands with xargs?

為{幸葍}努か 提交于 2019-12-18 10:35:36
问题 I have the following alias in my .aliases: alias gi grep -i and I want to look for foo case-insensitively in all the files that have the string bar in their name: find -name \*bar\* | xargs gi foo This is what I get: xargs: gi: No such file or directory Is there any way to use aliases in xargs, or do I have to use the full version: find -name \*bar\* | xargs grep -i foo Note: This is a simple example. Besides gi I have some pretty complicated aliases that I can't expand manually so easily.