tcsh

How can I use aliased commands with xargs?

大兔子大兔子 提交于 2019-11-29 22:59:44
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. Edit: I used tcsh , so please specify if an answer is shell-specific. Aliases are shell-specific - in

Generate a random filename in unix shell

喜夏-厌秋 提交于 2019-11-29 19:47:39
I would like to generate a random filename in unix shell (say tcshell). The filename should consist of random 32 hex letters, e.g.: c7fdfc8f409c548a10a0a89a791417c5 (to which I will add whatever is neccesary). The point is being able to do it only in shell without resorting to a program. Assuming you are on a linux, the following should work: cat /dev/urandom | tr -cd 'a-f0-9' | head -c 32 This is only pseudo-random if your system runs low on entropy, but is (on linux) guaranteed to terminate. If you require genuinely random data, cat /dev/random instead of /dev/urandom . This change will make

How can I echo commands in a tcsh script?

最后都变了- 提交于 2019-11-29 03:14:41
Yes. I know I shouldn't be using it for scripting. Yes. It is rubbish. I am indeed a fool. Nevertheless. I'd like to see the commands the script is executing, for debugging purposes. I think you get this effect with set -x or set -v in bash scripts. So e.g., if the script were #!/bin/tcsh echo "Hello" then when it ran, I'd see echo "Hello" Hello Put: set echo and/or set verbose at the top of your script. That will print out everything that happens in your script and are equivalent to the bash set -x and set -v commands. Lets say your script name is tcsh_file Lets assume this file includes

Escaping double quotes with tcsh alias

落爺英雄遲暮 提交于 2019-11-28 13:51:30
I'm trying to run the following commands: replace -x "must " A2input.txt replace -x " a" -f -s ## A2input.txt replace -x to -s ## -a A2input.txt replace -x faith -f "unequivocal" A2input.txt And it'd be nice if I could just alias it to something short and simple like "a", "b", "c", "d", etc... However, some of those arguments have a quote, which is messing up the alias. Does anyone know how to actually escape the double quotes? I've tried things like '\"' and \" but nothing seems to work. I'm using tcsh as my shell. I got it to work by storing the string with the double quote in a variable

Check if a file is executable

六月ゝ 毕业季﹏ 提交于 2019-11-28 05:11:11
I am wondering what's the easiest way to check if a program is executable with bash, without executing it ? It should at least check whether the file has execute rights, and is of the same architecture (for example, not a windows executable or another unsupported architecture, not 64 bits if the system is 32 bits, ...) as the current system. Take a look at the various test operators (this is for the test command itself, but the built-in BASH and TCSH tests are more or less the same). You'll notice that -x FILE says FILE exists and execute (or search) permission is granted . BASH, Bourne, Ksh,

What do >! and >>! do in tcsh

佐手、 提交于 2019-11-27 21:19:18
In normal bash redirection > redirecting standard output to a file, overwriting when it exists and >> redirecting standard output to a file, appending when it exists. In a tcsh (c shell) script I found the operators >! >>! being used. What do this operators do? tcsh does also have the > and >> operators, so what is the difference? In tcsh redirection the ! symbol means overwrite the existing file even if noclobber is set. In other words, if noclobber is set then: cmd > file will write stdout to file if file does not exist cmd > file will fail if file exists cmd >> file will append stdout to

How can I echo commands in a tcsh script?

吃可爱长大的小学妹 提交于 2019-11-27 17:27:19
问题 Yes. I know I shouldn't be using it for scripting. Yes. It is rubbish. I am indeed a fool. Nevertheless. I'd like to see the commands the script is executing, for debugging purposes. I think you get this effect with set -x or set -v in bash scripts. So e.g., if the script were #!/bin/tcsh echo "Hello" then when it ran, I'd see echo "Hello" Hello 回答1: Put: set echo and/or set verbose at the top of your script. That will print out everything that happens in your script and are equivalent to the

Is there an equivalent source command in Windows CMD as in bash or tcsh?

爱⌒轻易说出口 提交于 2019-11-27 07:48:30
I know that in the unix world, if you edit your .profile or .cshrc file, you can do a source ~/.profile or source ~/.cshrc to get the effect on your current session. If I changed something in the system variable on Windows, how can I have it effect the current command prompt session without exiting the command prompt session and opening another command prompt session? I am afraid not, but you can start using Powershell, which does support dot sourcing. Since powershell window is really based on cmd so all your dos command will continue to work, and you gain new power, much more power. In the

Specify command line arguments like name=value pairs for shell script

邮差的信 提交于 2019-11-27 07:03:40
问题 Is it possible to pass command line arguments to shell script as name value pairs, something like myscript action=build module=core and then in my script, get the variable like $action and process it? I know that $1....and so on can be used to get variables, but then won't be name value like pairs. Even if they are, then the developer using the script will have to take care of declaring variables in the same order. I do not want that. 回答1: In the Bourne shell, there is a seldom-used option '

Changing default shell in Linux [closed]

三世轮回 提交于 2019-11-27 02:22:25
How is it possible to change the default shell? The env command currently says: SHELL=/bin/tcsh and I want to change that to Bash. Summer_More_More_Tea Try linux command chsh . The detailed command is chsh -s /bin/bash . It will prompt you to enter your password. Your default login shell is /bin/bash now. You must log out and log back in to see this change. The following is quoted from man page: The chsh command changes the user login shell. This determines the name of the users initial login command. A normal user may only change the login shell for her own account, the superuser may change