command-line

How do you delete N files of X type from Y subfolders from a Windows batch file?

I'm trying to write a windows batch file that can delete files from subdirectories. I would rather not hard code the directory structure in, so I can use this process with other projects. I need to delete files of X type I have the parent folder C:\MyProject There are Y subfolders C:\MyProject\? There are N files to delete Is there...

Prevent duplicates from being saved in bash history

I'm trying to prevent bash from saving duplicate commands to my history. Here's what I've got: shopt -s histappend export HISTIGNORE='&:ls:cd ~:cd ..:[bf]g:exit:h:history' export HISTCONTROL=erasedups export PROMPT_COMMAND='history -a' This works fine while I'm logged in and .bash_history is in memory. For example: $ history 1 vi...

What are the differences between osql, isql, and sqlcmd?

I am interested in using some kind of a command-line utility for SQL Server similar to Oracle's SQL*Plus. SQL Server seems to have several options: osql, isql, and sqlcmd. However, I am not quite certain which one to use. Do they all essentially do the same thing? Are there any situations where it is preferable to use one over the other...

Output to command-line if started from command line

I'm writing an application that can be started either as a standard WinForms app or in unattended mode from the command-line. The application was built using the VS 2k5 standard WinForms template. When the application is executed from the command-line, I want it to output information that can be captured by the script executing the appl...

C# version of optparse?

Is there a C# port of the optparse (command line option parser) module from Python available under some OSI-approved license? ...

MS DOS edit a file

I am writing a batch script which I wish to open a file and then change the second line of it. I want to find the string "cat" and replace it with a value that I have SET i.e. %var% . I only want this to happen on the second line (or for the first 3 times). How would you go about doing this? ...

Build several CDT C++ projects from commandline

What is the best solution to build several CDT C++ projects from the command line? The projects have references and so it is not possible to just build single projects. ...

How can I delete the contents of a folder from the command prompt in windows?

I am writing a deployment script using MSBuild. I want to clean my web directories prior to copying all the new files in. My current "Clean" target looks like this: <Target Name="Clean"> <Exec Command="del %(DeploymentSet.LocalWebRoot)\* /Q /F /S" IgnoreExitCode="true" /> </Target> This takes an considerable amount of time as e...

Open a file in Visual Studio at a specific line number

Greetings, I have a utility (grep) that gives me a list of filenames and a line numbers. After I have determined that devenv is the correct program to open a file, I would like to ensure that it is opened at the indicated line number. In emacs, this would be: emacs +140 filename.c I have found nothing like this for Visual Studio (dev...

How to pretty-print JSON script?

Is there a (*nix) command-line script to format JSON in human-readable form? Basically, I want it to transform the following: { foo: "lorem", bar: "ipsum" } ... into something like this: { foo: "lorem", bar: "ipsum" } Thanks! ...

Command line tool to find Dll dependencies

Does anybody know a command line tool to recursively find a DLL dependencies? I tried dumpbin and depends that come with Visual Studio 2005, but dumpbin only finds the first level of dependencies, and depends output is not really computer friendly. ...

Best way to test command line tools?

I have a large collection of command line utilities that are we write ourselves and use frequently. At the moment testing them is very cumbersome and consequently we don't do as much testing as we aught to. I am wondering if anyone can suggest good techniques or tools for doing a good job of this kind of thing. Edit: to clarify this is...

How can I diff two files with full context?

I have two files with slight differences. A normal diff will show me the differences between the files. With -c or -u I can add an amount of context to each hunk. What options can I pass to diff to see every unchanged line alongside the changes, and get the diff as a single, large hunk? ...

How do I deal with quote characters when using cmd.exe

I've got a function: int RunProgram(string exeName, string parameters); (I'm actually trying to use the ViX API to automate a virtual machine... but I think the following question may apply in other circumstances). And I'm trying to do this: RunProgram("c:\\windows\\system32\\cmd.exe", "/C \"C:\\Program Files\\Somewhere\\SomeProgr...

How can I pass command-line arguments to a Perl program?

I'm working on a Perl script. First time in more than a decade. Really. How can I pass command line parameters to it? Example: script.pl "string1" "string2" ...

Implementing a "[command] [action] [parameter]" style command-line interfaces?

What is the "cleanest" way to implement an command-line UI, similar to git's, for example: git push origin/master git remote add origin git://example.com master Ideally also allowing the more flexible parsing, for example, jump_to_folder app theappname v2 jump_to_folder app theappname source jump_to_folder app theappname source v2 ju...

Using TFS, want to run a command line tool to perform obfuscation

Hi, First time using team explorer, and I want to add a build task that will run a command line tool to obfuscate the assembly. This will one of the last tasks to be performed I assume. How would I go about doing this using Team Explorer? ...

Is there a Python equivalent to `perl -pi -e`?

I know of python -c '<code>', but I'm wondering if there's a more elegant python equivalent to perl -pi -e '<code>'. I still use it quite a bit for things like find and replace in a whole directory (perl -pi -e s/foo/bar/g * or even find . | xargs perl -pi -e s/foo/bar/g for sub-directories). I actually feel that that which makes Perl ...

Which command line commands style do you prefer?

Vote up the one you like best! Use comments to justify your choice. As I know there are two types of command line commands. If you can think of another one, post an example (as a community-wiki answer). ...

Is there a good command line argument parser for Java?

Is there a good options parser framework/library for command-line programs written in Java? E.g. the equivalent of Python's optparse? ...