Tag Info

Hot answers tagged

107

Simply use brace expansion: mv /folder1/folder2/folder3/{file.txt,file-2013.txt} This is equivalent to writing: mv /folder1/folder2/folder3/file.txt /folder1/folder2/folder3/file-2013.txt Brace expansion lets you supply more arguments, of course. You can even pass ranges to it, e.g. to create a couple of test folders, you can run mkdir test_{a..z}, and ...


19

If you want clever, here's bash history expansion mv /folder1/folder2/folder3/file.txt !#:1:h/file-2013.txt I wouldn't use this myself since I find it impossible to memorize. I do occassionally use the vim equivalent, but have to look it up almost every time.


7

To elaborate a bit on my comment, I would suggest changing your script as follows: #!/bin/bash if [[ $1 = "32" ]] then rm config.h ln -s config32.h config.h rm Makefile ln -s Makefile32 Makefile echo "READY FOR 32 BITS!" elif [[ $1 = "64" ]] then rm config.h ln -s config64.h config.h rm Makefile ln -s Makefile64 Makefile echo "READY FOR ...


3

You'll have to use a feature the noscript author calls 'ABE', accessible through noscript options->advanced->ABE the syntax looks something like this: # comment # .example.com includes example.com and subdomains of example.com # example.com includes example.com but excludes its subdomains #Allow akamaihd scripts and objects to be included only from ...


3

Start up Automator Choose application In the Actions bar, select Library, and search for Shell Drag "Run Shell Script" to the right pane. Change pass input to "as arguments" Change the script to /usr/bin/python "$@" Save it (possibly in the application folder, but can be anywhere) as Python.app Now if you want .py files to always launch with python: ...


2

This is due to the mechanics of ps and top. Top simply aggregates usage by PID, and the System call in Perl essentially uses the OS' native fork(), which creates a child process. Child processes have the same PID as the parent. ps enumerates all running processes. For instance, note that the same thing is true of Apache. If you do Top and find Apache, ...


2

I like the other solutions, but here is another, implemented as a script with bash arrays, pushd, popd: #!/bin/bash set -e # from http://stackoverflow.com/a/246128/178651 script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # paths relative to the script relative_paths=( \ path1 \ path2 \ path3 \ path4 ) for relative_path in ...


2

If I understand you correctly, you are asking how to pass values to a bash script. This is very easy, for example: #!/usr/bin/env bash directory=$1; echo "Directory is $directory" $1 is the first command line argument of a bash script. $2 is the second etc etc. So, you could run the script above like so: ./foo.sh /path/to/bar Directory is /path/to/bar ...


2

Most likely WInactivate does not work because you need to add SetTitleMatchMode, 2 at the top of your script. To test if WinActivate really works use this: SetTitleMatchMode, 2 #c:: Run "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -start-maximized --new-window www.google.com WinWait, google ;Give Chrome a chance to start before testing ...


1

Nmap's normal output is not suited to parsing since it varies from version to version and does not use consistent delimiters or field widths. A better approach would be to use the XML or the Grepable output. The fastest and simplest for what you want would be to choose the Grepable output with -oG and send the output to STDOUT to be processed with awk: nmap ...


1

The beauty of powershell is that you get full-blown .NET objects that you can inspect. In the case of dates, powershell uses the DateTime class which exposes MOnth and Year properties that you can take advantage of: gci "\\servername\sharename\foldername\subfoldername\*.zip" | ?{ $lwt = $_.LastWriteTime; ($lwt.Month -eq ((get-date).Month-1)) -and ...


1

Your question isn't clear but if you want to write a script to execute another file, Try below command: if [ -f /home/sepahrad/MyFile ]; then ./MyFile fi When you execute your file it executes MyFile commands one by one. You have to replace your file address instead of /home/sepahrad/MyFile.


1

The xargs command with the -I option does exactly that: xargs -I {} yourcommand ... {} ... < yourinputfile where ... are the remaining arguments of your command (if any). The {} part is replaced by every line from yourinputfile.


1

Seems like it would be easier to just fire up the terminal and type "python /path-to-script/scriptname"? If not, there's apparently a way to get Apple script to do this, according to this stack overflow post: http://stackoverflow.com/questions/14793391/easy-way-to-launch-python-scripts-with-the-mouse-in-os-x In either case, you'll need to know the full path ...


1

This seems to work very well Public function GetOS(ServerName) Set objWShell = CreateObject("WScript.Shell") Set objCmd = objWShell.Exec("nmap -O -v " & ServerName) strPResult = objCmd.StdOut.Readall() set objCmd = nothing: Set objWShell = nothing GetOS = "Unknown" if InStr(strPResult,"OS details:")>0 then ...


1

As explained in the manual, all scripts run with sh -e. That means any unhandled command failure will terminate the script with an error. If you have code which might return failure, you would code it like command || true or wrap it in a conditional or something. By the by, your code is better written as ps ax | grep "[p]ostgres: wal writer process" ...


1

To identify the drive letter that the share is currently mapped to and unmap it: @echo off for /f "tokens=2" %%D in ('net use ^| find ":" ^| find "\\server\share") do net use %%D /delete Comments: ^ is like \ in Unix –– it turns the following character from special to non-special, or vice-versa.  We use ^| so that the interpretation of the | characters ...


1

Both irssi and Weechat have per-channel encodings. Weechat (scriptable in Perl, Python, Ruby, Tcl, Guile and C [plugins]; actively developed) For current buffer: /charset encode koi8-r /charset decode koi8-r For a given buffer: /set charset.encode.irc.freenode.#postfix-ru koi8-r /set charset.decode.irc.freenode.#postfix-ru koi8-r For a given ...


1

As others have already said, you need to rely on an external service. I'd recommend http://www.exip.org You can use http://api.exip.org?call=ip to get the ip in plain text format. It's fast and reliable, plus it supports ipv6.



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