Uses 'seq' with formatting parameter to generate the necessary padded sequence. Change '%02.0f' to how many digits you need (for 3, use %03.0f, etc) and replace 5 & 15 with your desired min and max. Show Sample Output
Require "grep -P" ( pcre ).
If you don't have grep -P, use that :
grep -Eo '"url":"[^"]+' $(ls -t ~/.mozilla/firefox/*/sessionstore.js | sed q) | cut -d'"' -f4
I used to do a lot of path manipulation to set up my development environment (PATH, LD_LIBRARY_PATH, etc), and one part of my environment wasn't always aware of what the rest of the environment needed in the path. Thus resetting the entire PATH variable wasn't an option; modifying it made sense.
The original version of the functions used sed, which turned out to be really slow when called many times from my bashrc, and it could take up to 10 seconds to login. Switching to parameter substitution sped things up significantly.
The commands here don't clean up the path when they are done (so e.g. the path gets cluttered with colons). But the code is easy to read for a one-liner.
The full function looks like this:
remove_path() {
eval PATHVAL=":\$$1:"
PATHVAL=${PATHVAL//:$2:/:} # remove $2 from $PATHVAL
PATHVAL=${PATHVAL//::/:} # remove any double colons left over
PATHVAL=${PATHVAL#:} # remove colons from the beginning of $PATHVAL
PATHVAL=${PATHVAL%:} # remove colons from the end of $PATHVAL
export $1="$PATHVAL"
}
append_path() {
remove_path "$1" "$2"
eval PATHVAL="\$$1"
export $1="${PATHVAL}:$2"
}
prepend_path() {
remove_path "$1" "$2"
eval PATHVAL="\$$1"
export $1="$2:${PATHVAL}"
}
I tried using regexes to make this into a cleaner one-liner, but remove_path ended up being cryptic and not working as well:
rp() { eval "[[ ::\$$1:: =~ ^:+($2:)?((.*):$2:)?(.*):+$ ]]"; export $1=${BASH_REMATCH[3]}:${BASH_REMATCH[4]}; };
Show Sample Output
Thank You, hackerb9!
Clears the package cache of all uninstalled packages. Does not remove package configuration files in user's home directory.
Helps if you accidentally deleted files from an svn repo with plain rm and you would like to mark them for svn to delete too.
Archive all .sh files in a directory into a gzip archive.
or add this line to your ~/.vimrc if using vim
I can't find the lid command on my system, there is also another complied program: http://xyne.archlinux.ca/projects/lsgrp/
Good for when you download youtube videos and want the mp3 for your mp3 player.
The idea is to get the current branch name directly using git symbolic-ref --short HEAD name and not type it manually. Show Sample Output
I don't know why you would want to echo "blocking ....", but my alternative is functionally equivalent with the extra echo.
For example to add up the disk usage at several disjoint locations. The $[..] is for arithmetic evaluation in bash. Alternatively pipe to the bc command. Show Sample Output
emulates bash4's "echo {03..20}" Uses bash3 builtin function printf Show Sample Output
commandlinefu.com 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.
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.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
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: