Tag Archives: Command line

Pretty print XML on Unix command line

Needed to check some XML output from a CalDAV service so I used curl, which is nice and simple. Only problem was that all the XML came back on a single long unreadable line. Turned out it wasn’t too difficult to get it formatted:

$ curl --digest --user usr:pwd -X PROPFIND  | xmllint --format -

The key part here is of course the piping into xmllint. --format tells it to format the XML and the - tells it to read the XML from standard in. The dash can be swapped with the path to an XML file, if you need to format already downloaded XML.

$ xmllint --format file.xml

Simple pimple dimple 🙂

How to run PowerShell scripts directly from Windows command line

If you find yourself in the regular command line (cmd.exe) on Windows and you’d like to run a PowerShell script, you can do it like this:

> powershell ./example-script.ps1

Would be nice if you could just run it directly as a bat file though, right? And yes, you can! Continue reading How to run PowerShell scripts directly from Windows command line

How to change or remove file extensions in Windows

Say you have a bunch of files and you want to quickly change or remove the file extension of all of them. Turns out that’s very simple to do with the command-line in Windows. I had no idea…

Change

ren *.old *.new

Will change all files with ‘old’ file extension to have the ‘new’ file extension.

Remove

ren *.old *.

Will remove the ‘old’ file extension.

Simple!