Bash Pattern Matching Operator

GNU Bash (4.2 as of this post)’s manual page says that its pattern matching operator =~

value =~ pattern

uses the ERE (Extended Regular Expression syntax) specification used by regex(3) which is theĀ POSIX 1003.2 regular expressions format. Also, =~ has the same precedence as the == and != operators.

This is documented in the SHELL GRAMMAR section – Compound Commands – [[ expression ]].

pythonbrew environment manager

The pythonbrew utility is a complete environment manager for Python. It allows one to list and switch permanently between python versions or just as a temporary in the current shell session.

Usage syntax is very simple:

pythonbrew command [options]

And here are some command examples from its README document (that file on github also includes the installation procedure), showcasing its set of features:

# Install some pythons:
pythonbrew install 2.7.2
pythonbrew install --verbose 2.7.2
pythonbrew install --force 2.7.2
pythonbrew install --no-test 2.7.2
pythonbrew install --configure="CC=gcc_4.1" 2.7.2
pythonbrew install --no-setuptools 2.7.2
pythonbrew install http://www.python.org/ftp/python/2.7/Python-2.7.2.tgz
pythonbrew install /path/to/Python-2.7.2.tgz
pythonbrew install /path/to/Python-2.7.2
pythonbrew install 2.7.2 3.2
 
# Permanently use the specified python:
pythonbrew switch 2.7.2
pythonbrew switch 3.2
 
# Use the specified python in current shell:
pythonbrew use 2.7.2
 
# Runs a named python file against specified and/or all pythons:
pythonbrew py test.py
pythonbrew py -v test.py # Show verbose output
pythonbrew py -p 2.7.2 -p 3.2 test.py # Use the specified pythons
 
# List the installed pythons:
pythonbrew list
 
# List the available installation pythons:
pythonbrew list -k
 
# Uninstall the specified python:
pythonbrew uninstall 2.7.2
pythonbrew uninstall 2.7.2 3.2
 
# Remove stale source folders and archives:
pythonbrew cleanup
 
# Upgrades pythonbrew to the latest version:
pythonbrew update
pythonbrew update --master
pythonbrew update --develop
 
# Disable pythonbrew:
pythonbrew off
 
# Create/Remove a symbolic link to python (in a directory on your $PATH):
pythonbrew symlink # Create a symbolic link, like "py2.7.2", for each installed version
pythonbrew symlink -p 2.7.2
pythonbrew symlink pip # Create a symbolic link to the specified script in bin directory
pythonbrew symlink -r # Remove a symbolic link
pythonbrew symlink -v foo # Create a symbolic link to the specified virtual environment python in bin directory
 
# Runs the buildout with specified or current using python:
pythonbrew buildout
pythonbrew buildout -p 2.6.6
 
# Create isolated python environments (uses virtualenv):
pythonbrew venv init
pythonbrew venv create proj
pythonbrew venv list
pythonbrew venv use proj
pythonbrew venv delete proj
 
# Show version:
pythonbrew version

Xfce Shortcut for ALSA Sound Attenuation

Xfce is one of the greatest desktop environments ever. It is beautiful, lean, and thus it is also very fast.

One of its great customizable aspects is the assignment of commands for Keyboard Shortcuts (Xfce Menu > Settings > Keyboard > Application Shortcuts).

I immediately found out two nice applications for it: screenshot and sound attenuation. This post gives you the hint on the sound attenuation command when using ALSA (Advanced Linux Sound Architecture).

I usually cycle between 40% of the card’s volume when attenuated and 80% when playing audio normally. So I took the keys F9 and F10, respectively, and assigned them the following ALSA commands, also respectively:

amixer set Master 40%

and

amixer set Master 80%

The “Master” simple mixer control name I knew via listing the simple mixer controls available via the

amixer scontrols

command. Do the same and substitute “Master” in the commands above with whatever value you see in place of the blue value below (“Master”, in this example, matching the “Master” in the above commands):

Simple mixer control 'Master',0
Simple mixer control 'PCM',0
Simple mixer control 'IEC958',0
Simple mixer control 'IEC958 Default PCM',0
Simple mixer control 'Digital',0
Simple mixer control 'Ext Mic',0
Simple mixer control 'ExtMic',0
Simple mixer control 'Int Mic',0
Simple mixer control 'IntMic',0

Enjoy! :)

LinuxQuestions.org All Things Linux

Whether you are looking for Linux distributions downloads, or a Linux forum, for cool surveys, or wanting to contribute to the active Linux community in general, one of the best places to get started and have it bookmarked is the LinuxQuestions.org site.

At the iso section, you can download your choice among a myriad of distributions. According to its community bulletin on November, 16th, there are over 1,600 versions available from 1,700 mirrors, and the count of facilitated downloads surpassed 15 million!

To help fellow colleagues who don’t have a clue on how to solve their problems, you can also trace the Zero Reply Threads via the specific site section, or register to the respective feed.

Importance of Rounding Partitions up to Cylinders

GParted Gnome Partition Editor Link

The GParted (Gnome Partition Editor) disk partitioning tool provides you with the ability to round up a partition size to cylinders. What is the importance of this? Linux v.s. MSDOS (read Microsoft, or Windows’) partition tables interpret it in different ways when they are not lay out like so.

Debian worked alright when the disk was not partioned in this way. Nevertheless, if you do not want to have headaches e.g. when backing up the information on the extended partitions with the sfdisk utility, which complains if the alignment condition does not apply to your environment, then do the alignment.

Note: to backup the partition table (with information on the primary partitions) you use a simple tool as dd. However, the information on the extended partitions lies on an indirect table pointed to by the main, raw partition table. So this information needs to be accessed by dereferencing such a pointer. The sfdisk utility does just that.

To do so, I used GParted (it provides its own live cd, and it is also provided by several system rescue focused distributions like Parted Magic and the Gentoo-based SystemRescueCd, and many others) and as soon as the system was back online I made the backup with sfdisk without it complaining at all.