Commands tagged xpath (5)

  • I look at xkcd in my news reader, but it displays the image's title attribute only for a few seconds which makes reading the longer ones more challenging. So I use this to display it in my console.

    curl -s '' | xpath '//item[1]/description/text()' 2>&1 | sed -n 's/.*title="\([^"]*\)".*/\1/p' | fold -s
    putnamhill · 2013-02-16 22:38:26 0
  • Ever wanted to stream your favorite podcast across the network, well now you can. This command will parse the iTunes enabled podcast and stream the latest episode across the network through ssh encryption. Show Sample Output

    curl -L -s `curl -s` | xmlstarlet sel -t -m "//enclosure[1]" -v "@url" -n | head -n 1` | ssh -t [user]@[host] "mpg123 -"
    denzuko · 2010-07-30 23:20:50 0
  • Gets the latest podcast show from from your favorite Podcast. Uses curl and xmlstarlet. Make sure you change out the items between brackets.

    curl -L -s `curl -s []` | xmlstarlet sel -t -m "//enclosure[1]" -v "@url" -n | head -n 1` | ssh -t [user]@[host] "mpg123 -"
    denzuko · 2010-07-31 00:17:47 0
  • This function uses xmllint to evaluate xpaths. Usage: xpath /some/xpath XMLfile Show Sample Output

    xpath () { xmllint --format --shell "$2" <<< "cat $1" | sed '/^\/ >/d' }
    sharfah · 2011-10-05 07:45:16 1
  • This function uses xmllint to evaluate xpaths. Usage: xpath /path/to/element XMLfile

    xpath () { xmllint --format --shell "$2" <<< "cat $1" | sed '/^\/ >/d' }
    sharfah · 2011-12-20 08:34:11 0

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

Create a mirror of a local folder, on a remote server
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22) (all files & folders on destination server/folder will be deleted)

show how many regex you use in your vim today
i want to count how many regex code i have used in vim in a long time so i make a directory in svn host and post record to this directory of course i dont want to post manually so i worte a script to do that and this is the core thing to do

List only the directories
This command would be useful when it is desirable to list only the directories. 'egrep' chooses only the lines that begin with 'd'.

Recursively remove directory with many files quickly
rsync'ing an empty directory over a directory to be deleted recursively is much faster than using rm -rf, for various reasons. Relevant only for directories with really a lot of files.

How many days until the end of the year

add all files not under version control to repository
This should handle whitespaces well and will not get confused if your filenames have "?" in them

Install pip with Proxy
Installs pip packages defining a proxy

Install an mpkg from the command line on OSX
Installing most OSX apps is just a matter of dropping it in /Applications, either GUI-wise or with cp -r. However, many packages are distributed in "mpkg" format, and those have to be installed with an installer. If you don't want to go to the trouble of firing up VNC to install an mpkg, you can use the "installer" command. This will install an application from a .mpkg it to /Applications system-wide. To install a program for just one user, replace "-target /" with "-target username".

Get a Bulleted List of SVN Commits By a User for a Specifc Day (Daily Work Log)
* Replace USERNAME with the desired svn username * Replace the first YYYY-MM-DD with the date you want to get the log (this starts at the midnight event that starts this date) * Replace the second YYYY-MM-DD with the date after you want to get the log (this will end the log scan on midnight of the previous day) Example, if I want the log for December 10, 2010, I would put {2010-12-10}:{2010-12-11}

check open ports without netstat or lsof

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: