An automated series of instructions carried out in a specific order, such as a Windows script created to launch a specific program on startup.

learn more… | top users | synonyms (1)

112
votes
17answers
56k views

How to execute a command whenever a file changes?

I want a quick and simple way to execute a command whenever a file changes. I want something very simple, something I will leave running on a terminal and close it whenever I'm finished working with ...
65
votes
6answers
4k views

How do I perform commands in another folder, without repeating the folder path?

Is there a clever way to do copy and move operations or a command to duplicate a file, without having to do a cd, then mv after, at the same folder? For example, I have to run the following: mv ...
61
votes
13answers
18k views

Add directory to $PATH if it's not already there

Has anybody written a bash function to add a directory to $PATH only if it's not already there? I typically add to PATH using something like: export PATH=/usr/local/mysql/bin:$PATH If I construct ...
56
votes
6answers
18k views

What is the difference between executing a bash script and sourcing a bash script?

What is the difference between executing a bash script like A and sourcing a bash script like B? A >./myscript B >source myscript
38
votes
9answers
8k views

What scripting languages are useful in Windows? [closed]

What scripting languages are useful for Windows automation?
35
votes
10answers
5k views

How can I delete everything after the first column in Notepad++?

I'm trying to get rid of everything after a column in Notepad++. Column mode is not an option. Is it possible? What I have: 70.97.110.40 159 ms [n/a] 21 ...
32
votes
9answers
68k views

How can I run an application with command line arguments in Mac OS

Is there any easy way to append command line arguments to an application on a Mac? For example, to run Opera in kiosk mode or to use a different profile in Firefox, I can type $ ...
31
votes
12answers
56k views

Which command can I use to recursively rename or move a file in Windows?

What command in Windows emulates the recursive move / rename command from Unix?
30
votes
2answers
20k views

How to launch a command on network connection/disconnection?

I have a wifi connection that requires to authenticate using a web form once the wireless link is established. I know how to automate the authentication with a script that uses curl/curlIE. But how ...
30
votes
7answers
43k views

How can I get a script to run every day on Mac OS X?

Cron? Launchd? iCal?? If so, how?
30
votes
2answers
34k views

SSH: execute sudo command

I have an interactive shell script, that at one place needs to ssh to another machine (Ubuntu based) and execute something as root (the user should enter his password, but the remote command should ...
25
votes
2answers
13k views

Bash Shebang for dummies?

I have some bash scripts I have setup that mostly use #!/bin/bash but I regularly come across some that look like #!/bin/bash -e #!/bin/bash -x #!/bin/bash -ex and so on. Can someone explain ...
22
votes
7answers
93k views

Running bat file at startup as administrator in Windows 7

I'm currently running a startup script in form of a bat file successfully in Windows 7 (I've inserted a new registry key entry with the bat file path as value in ...
21
votes
4answers
14k views

Looping Through Subdirectories and Running a Command in Each

I have a set of repositories sorted into directories based on their VCS (Git, Mercurial, SVN). With Subversion I was able to run svn update * in the parent directory and it would loop through each ...
17
votes
2answers
12k views

zsh with Cygwin

How can I configure zsh to be the default shell under Cygwin?
17
votes
5answers
3k views

Good PowerShell guide, getting started through more advanced usage

Does anyone have a really good tutorial or getting started guide for Microsoft's PowerShell? I'm a long time Linux/Unix user, and very familiar with scripting languages, command-line usage with bash, ...
16
votes
4answers
11k views

Should I put *.sh and *.rb file extensions on all my scripts?

I have a bunch of hand-rolled executable scripts in my $HOME/bin directory. Some are written in bash, some in Ruby. All of them have the shebang line at the top telling the shell what interpreter to ...
16
votes
7answers
5k views

Determine if command is recognized in a batch file

I'm writing a bat script in which I invoke a program (such as javac). For simplicity, I want to check if the command exists before I run it. i.e. If the command exists in PATH. For example, if ...
15
votes
3answers
2k views

Multiple standard input? How?

From this commandlinefu post: $ diff <(wget -q -O - URL1) <(wget -q -O - URL2) Seems like multiple standard inputs but---if I remember my Linux Porgramming course correctly---this can't be ...
14
votes
5answers
37k views

Automatically run a script when I log on to Windows

How can I automatically run a script when I log on to Windows? I'd like to run this whenever I log into my computer: echo %USERNAME% logged on at %DATE% %TIME% >> log.txt A bonus would be to ...
14
votes
5answers
32k views

Change DNS with script

I need to frequently change the DNS server address, and for now I do it by opening 'network and sharing center' - 'local area connection' - properties - ipv4 - and then type the DNS numbers. Is there ...
13
votes
8answers
1k views

Bash Script to repeat every word in a line?

I have a string like: dog cat bird whale And I want to get dog dog cat cat bird bird whale whale All the words are in the same line. Any idea?
13
votes
2answers
64k views

How do I concatenate strings in a bash script?

How can I concatenate strings and variables in a shell script? stringOne = "foo" stringTwo = "anythingButBar" stringThree = "? and ?" I want to output "foo and anythingButBar"
13
votes
3answers
13k views

How to execute a command in screen and detach?

How can I get screen to execute a command and then detach (That is, automatically in a single script without further input beyond initially starting the script)? e.g. I run myscript.sh and it ...
13
votes
4answers
4k views

How to sync GreaseMonkey scripts between computers?

I have some great greasemonkey scripts for FireFox and would ideally have a way to sync them between computers. To some degree, it would even be nice to be able to deploy the scripts to PC's across a ...
13
votes
2answers
18k views

How can I access volume levels from the command line on Windows 7?

What I need I'm looking for a tool or a script that allows me to access the Windows volume levels from the command line. Ideally it would allow me to get and set all volumes including application ...
12
votes
4answers
26k views

Remotely run script on Unix, get output locally?

I need to run a (Tcl, or whatever) script on a remote Unix machine, from a (local) Windows command shell, and I want the stdout/stderr of the script to show up in the Windows CLI. The exit code would ...
12
votes
5answers
22k views

What tool can generate MD5 from the command-line? [closed]

Is there any tool that can automate by script to generate file MD5? I used to use Cygwin but I am looking for another solution without having Cygwin installed.
12
votes
3answers
11k views

Create a logoff script/task for Linux

In similar vein to my question for Windows and Mac OS X, how would one go about creating a logoff script for Linux? Any distro is fine, as I'm sure it'd be extendable across others. I'm most ...
12
votes
2answers
18k views

Can I make a script always execute as root?

How to make a script execute as root, no matter who executes it? I read about setuid but I'm not sure how to do this. I'm using Linux, Ubuntu 12.04 LTS.
11
votes
6answers
2k views

A script so that you don't forget your usb drive on a public computer

So I have a problem because I'm an idiot. I seem to always leave my usb drives in public computers at school and the like. I unmount them and log off leaving them still in the pc, and of course I then ...
11
votes
3answers
5k views

How do I launch a bash script from Finder in OS X?

How do I launch a bash script from Finder in OS X? I'm OK working at the CLI, but my little script is not so loved by my GUI-bound colleagues.
11
votes
1answer
7k views

Is there a way to call a script when Ubuntu wakes up from suspend or hibernate mode?

I have a little shell script that I run automatically when I log on to my Ubuntu machine; it will set the parameters of my touchpad the way I like it. However, when Ubuntu wakes up after being ...
11
votes
4answers
3k views

How to set a Linux Ditribution to self-destruct (to wipe everything from the system partition) via a script

I know this is a rather strange question, but I actually need to implement something like this for work. I shall be helping to facilitate a course that uses licensed software. The software is somewhat ...
11
votes
5answers
3k views

Move some iTunes library items to different drive?

My internal hard drive is somewhat small, and I only regularly listen to a fraction of my iTunes library anyway, so I'd like to keep large portions on it on an external drive for archival purposes. ...
10
votes
8answers
36k views

How to get my external IP address (over NAT) from the Windows command-line?

The Windows "ipconfig" command can only show me the parameters from the Ethernet interfaces from my machine (even with the ipconfig /all argument). It can show detailed information about the ...
10
votes
3answers
2k views

Calling a script with ./bla.sh vs. . bla.sh

Can anybody explain to me what the shell does in the two examples A) and B) below? It obviously behaves differently, but I can't find out why the output is different. Example: Let's have a script in ...
10
votes
2answers
729 views

What's the difference between the following cmd scripts?

I've tried launching several programs through a batch file and encountered problems but that is in the past. I'm relatively new to scripts and command lines and this would be my question: What's the ...
10
votes
9answers
6k views

How to clean up output of linux 'script' command

I'm using the linux 'script' command http://www.linuxcommand.org/man_pages/script1.html to track some interactive sessions. The output files from that contain unprintable characters, including my ...
10
votes
5answers
18k views

When to use Bash and when to use Perl/Python/Ruby?

We are doing all our scripting with Bash so far, but I'm starting to feel a bit silly about it. While we can of course do everything we want with Bash (it's quite powerful), I'm starting to wonder if ...
10
votes
2answers
21k views

Linux Bash Script, Single Command But Multiple Lines?

I have the following script I wrote by searching Google, and it backs up my Linux system to an archive: #!/bin/bash # init DATE=$(date +20%y%m%d) tar -cvpzf ...
10
votes
1answer
8k views

does %* in batch file mean all command line arguments?

does %* in batch file mean all command line arguments?
9
votes
1answer
10k views

Run a batch command for every file in a directory

I have a Java program working with this syntax: command.jar namefile I have to run this program for 1600 files in a directory. How can I run this command for every file automatically? Is there a ...
9
votes
2answers
56k views

Schedule Auto Re-Boot of Windows Server 2008 R2

Is there any specific command or script through which I can schedule an Auto reboot of Windows Server 2008 R2?
9
votes
4answers
26k views

Using Wget to Recursively Crawl a Site and Download Images

How do you instruct wget to recursively crawl a website and only download certain types of images? I tried using this to crawl a site and only download Jpeg images: wget --no-parent --wait=10 ...
8
votes
7answers
4k views

MacOS X: How to have a handy “Open this folder in iTerm” shortcut?

I think the title states exactly what I want to do. I want a shortcut or even a button within Finder which fires up a new iTerm Tab and changes the location to the location i've open in Finder. Some ...
8
votes
3answers
4k views

How to extract a complete list of extension types within a directory?

Within a directory, and recursively within it's sub-directories, meaning every directory within a directory is processed, how do I compile a complete list of unique extensions within the directory? ...
8
votes
4answers
53k views

How do I set the desktop background on Windows from a script?

On X Windows I had a cool 'silent-alarm" reminder script that would change my root window (background) color to solid red, just for a few seconds a few moments before changing it back. Is there a way ...
8
votes
2answers
9k views

How to extract text from pdf in script on Linux?

On Linux - How to extract text from a .pdf in which text really is text, not a scanned image? I want something I can use on the command line / in a script, not interactively. (I don't want to convert ...
8
votes
4answers
15k views

What's the easiest way to have a script run at boot time in OS X?

I want a script (bash/zsh/ruby/...) to run at boot time in OS X. What's the most simple way to do this, without messing with xml/plist files, and preferably not needing to make a meta AppleScript.