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 on a single long unreadable line. Figured out this was quite simple to fix.
$ curl --digest --user usr:pwd -X PROPFIND http://cal.example.com/cal.php/principals/usr/default | xmllint --format -
The key part here is of course the piping into
--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
Needed to check the HEAD of a URL on two Unix servers today. Goal was to check if routing, firewall and load balancer rules were all good. One server only had curl, and the other only had wget, so here are commands for both:
$ wget -S --spider http://geekality.net
$ curl -i -X HEAD http://geekality.net
Wanted to try out Ubuntu Server, but with a GUI.
Keep forgetting how to do this, so here it is. How to do a quick and simple, recursive search for text using
grep. Hint: It’s very simple.
That’s all there is to it!
grep is the command,
r makes the search recursive (i.e. in the target folder and all its sub-folders),
l means it will list the name of all the files where it finds the text,
"some text" is the string to search for, and finally, the dot at the end means to start the search in the current directory. And just to clarify, this searches for text inside of files, in the content of the files; not the filenames.
There, now I know where to find it when I forget it next time. And perhaps I have helped someone else too
Was on a Linux box today and I found the command prompt rather useless. It looked like this:
I know I’m using bash, and I don’t really care about the version. Or that I’m using bash actually… But anyways, to make it more useful you can run this:
You will then get a prompt which contains your username, hostname and current working directory. Much more useful in my opinion. If you have a different opinion, please share
You can find more stuff to put in your prompt by reading the prompting section of the bash man page.
To set the
JAVA_HOME environment variable you first need to find where your Java installation is located and then set it somehow.
If you run the following command on a Unix system you might see a lot of errors.
In my case I got 8 regular findings and 63 lines of “find: cannot read dir /foo: Permission denied”. Quite a lot of noise I really don’t care about. Using my new knowledge about streams it is easy to get rid of all that though. Just pipe stderr into