Tag Info

Hot answers tagged

45

From here: $# Stores the number of command-line arguments that were passed to the shell program. $? Stores the exit value of the last command that was executed. $0 Stores the first word of the entered command (the name of the shell program). $* Stores all the arguments that were entered on the command line ($1 $2 ...). ...


23

SET will set a global environment variable. It will persist after the execution of your script. Let's have a look at an example. First, I clear the variable to make sure it doesn't exist. C:\Users\Oliver\Desktop>set TEST= A quick test: C:\Users\Oliver\Desktop>echo %TEST% %TEST% Let's create that batch file and execute it: ...


9

In Bash shell: export FOO="/a/b/c" And you don't want to use $path. That's a special variable.


9

JavaScript is raw source code being interpreted on the client machine, so the short answer is no. The best you could perform as much work as you can on the server. Any JavaScript code you push to the client can be tampered with by the client.


7

I suggest you to try dir > "%USERNAME%.txt"


6

First: Go to the "Plugins" drop-down menu. Open the Plugins Manager. Download PythonScript for Notepad++. Via the prompt, restart Notepad++. Next: Go to Plugins in the drop-down menu. Click PythonScript->new script``. Save the script with a .py extension. Copy and paste this code, then edit it: #*** IMPORTS *** from Npp import * #*** ...


6

assuming you really want csh/tcsh syntax (as you have tagged your question), put this setenv P1 "/a/b/c/d/e/f" to your .tcshrc after that you are able to do cd $P1


6

It's not likely that you need your variable in the environment. So, in csh instead of setenv, you can do: set dir="/a/b/c/d/e/f" cd $dir or in Bash, instead of export: dir="/a/b/c/d/e/f" cd $dir


6

Put this in your var.vim plugin file: let $VIMHOME=expand('<sfile>:p:h:h') % in expand will refer to the file being edited (i.e. the pathname given on the command line). <sfile> will refer to the file being ‘sourced’ (i.e. the plugin or startup file that is active when the expansion is made). The :p modifier makes the pathname absolute and ...


6

Parameters can be received as $1, $2, etc., or $* for all of them. There is also the array $@, which is usually used as "$@" as a better version of $*. Another possible usage is ${@:3} which means "all arguments starting with 3rd". To get a command's output, use $( ... ) or its older form ` ... `. It is generally recommended to always use $() since it can ...


5

$path = "C:\folder" $name = "file.exe" $fullname = $path + "\" + $name $fullname (or) $fullname = "$path\$name" but not $fullname = '$path\$name' Output C:\folder\file.exe


5

BSD xargs does not have -i, and that option is deprecated in GNU xargs anyways (when was this guide written? 1995?). Use -I instead.


5

Your first guess was right, but you used a bad example.  When the shell reads the command foo=bar echo $foo the first thing it does (or, at least, one of the first things) is to look for variable references (like $foo) and evaluate them.  Then it processes what’s left of the line.  (This may be a bit of an oversimplification; see bash(1) or the Bash ...


4

Quote the variable: echo "$z" Without quotes each word in $z becomes a separate argument to echo, with quotes the whole variable is a single argument - newlines and all.


4

There will generally be some increase, but rarely near double. Some info here : http://www.codeguru.com/cpp/cpp/cpp%5Fmfc/tutorials/article.php/c15711/


4

Not directly, no. Entries in $PATH are not recursive. What you can do is: for d in /usr/local/bin/*/; do PATH+=":$d" done Another option is to put symlinks in /usr/local/bin: cd /usr/local/bin ln -s myapp-1.2/myapp myapp


4

From my understanding you need filever.exe to do this. As pointed out in the comments. Also, I ripped the below word for word from here How to use the Filever.exe tool to obtain specific information about a file in Windows From what I gather about filever's output it's always in columns and you want the fifth column (version). So a simple for should ...


3

There is none. It's for echoing a variable immediately followed by a string. For example, if you have $param, but you want to have right after it, "lbs" echo "${param}lbs" Where as echo "$paramlbs" Would look for an incorrect variable name


3

You are correct about .bashrc. On the initial boot, the OS knows nothing of environment variables except what it reads in .profilerc, .bashrc, .inputrc, etc. And anything exported only lasts for the current session unless placed in one of those files. If values are added to one of these files and you want it to take effect immediately, run: source ...


3

SET /A only works on integers. So there is no way to get 0.75 using that. And I know of no other way to do arithmetic in batch files.


3

If you're using Microsoft's CMD, then what Nifle said applies. However, if you are using JP Software's TCC/LE to replace it, not only is there another way to do arithmetic in command scripts, but it is not limited to integer arithmetic and the precision of the calculations is controllable. TCC/LE supports the /A option to the SET command, of course. But, ...


3

Windows XP one-liner (no IPv6 installed), note "findstr 192." - you may need to remove of adjust it (I use it to select necessary interface): for /F "tokens=2 delims=:" %%i in ('"ipconfig | findstr IP | findstr 192."') do SET LOCAL_IP=%%i echo %LOCAL_IP%


3

This is one of those questions that pretty much begs the response "What is your ultimate goal?" As stated by others, no, you can't. JavaScript is client side so entirely in the hands of the client, not you. Obfuscation, as heavyd mentions, could be useful, but it's certainly not a secure/sure-fire way to prevent it. If this is something you need for ...


3

Use export. export your_path="/a/b/c/d/e/f" cd $your_path If you want it to persist through logins, you're going to need to edit it into your .profile file.


3

The -i option to xargs is never needed when the place to perform the replacement is at the end of the string; that's where the filenames would be put anyway. And BSD xargs (which is what OSX provides) doesn't support that option either. So try this: grep -ilr --exclude=revar.sh --exclude=README.md "[DATE]" * | grep -v .git | xargs sed -i ...


3

How it exactly works Generate a list of file names: grep -ilr --exclude=revar.sh --exclude=README.md "[DATE]" * Search recursively (-r) for files and list (-l) the names of those where the contents of the file match case-insensitively (-i) the regex '[DATE]' (which means that the file contains any one of the 8 characters "AaDdEeTt"); exclude the names ...


3

:help hlsearch When there is a previous search pattern, highlight all its matches. so, put set hlsearch to your vimrc


3

For your third requirement, nnoremap , :mat Error "<C-R><C-W>"<CR> Put this in your vimrc file..Press comma to highlight all occurrences of the word at cursor. Also, pressing * or # will highlight all occurrences of the string at cursor when hlsearch is setedit:For your first requirement,vnoremap <silent> , :<C-U> \let ...


3

As ever so often, the answer lies in quoting. echo -n $TEST > text This will get expanded to: echo -n test > text Note the two spaces after test. The only arguments echo sees are -n and test. Nothing else. The space gets lost here. To keep it, you need to double-quote $TEST: echo -n "$TEST" > text See also: Quotes and escaping on the Bash ...


3

Put the assignment on a separate line from the local definition: local info info=( $(command df -P $fs | awk 'END{ print $2,$3,$5 }') )



Only top voted, non community-wiki answers of a minimum length are eligible