If you’ve got a string of items in bash which are delimited by a common character (comma, space, tab, etc) you can split that into an array quite easily. Simply (re)define the IFS variable to the delimiter character and assign the values to a new variable using the array=($<string_var>) syntax. The new variable will now [...]
Posts Tagged ‘linux’
Convert a delimited string into an array in Bash
Posted: 9th March 2012 by Tim in BashTags: array, Bash, delimiter, IFS, linux, OIFS, script, scripting, string, terminal, unix
Numlock on startup in Debian or Fedora
Posted: 26th February 2012 by Tim in Debian, FedoraTags: boot, Debian, Fedora, linux, numlock, on, start, startup, toggle
Annoyingly, numlock is not turned on by default in Debian or Fedora. Thankfully, the fix is simple. Firstly, install the numlockx program. This is a simple command line tool which can turn numlock on or off: Debian: apt-get install numlockx Fedora: yum install numlockx Next, add this to one of the startup scripts. I like [...]
Piping stderr in unix
Posted: 26th May 2011 by Tim in Bash, UbuntuTags: cerr, cout, fd, file descriptor, linux, pipe, redirect, stderr, stdout, unix
In unix, you can pass output from one program to another using the pipe symbol (|). Unfortunately, it only pipes the output from stdout (cout). You can pass the output from both stdout and stderr (cerr) by adding 2>&1 to the end of the command before the pipe, where 1 is the file descriptor for [...]
Ignoring the first line of output in a unix terminal
Posted: 31st January 2011 by Tim in Bash, Software Development, UbuntuTags: first line, ignore, linux, sed, sh, shell, terminal, Ubuntu, unix
Sometimes in a terminal you want to strip out the first line of output from a command. For example, you may want to generate a list of users which have tasks running using the ps command. This command puts a header at the top of the output. You can remove this header by piping the [...]
Converting CDs to MP3s in Ubuntu
Posted: 25th July 2010 by Tim in Debian, UbuntuTags: 320kbps, bitrate, CD, linux, mp3, sound juicer, Ubuntu
There are a number of ways to convert CDs into MP3s in Ubuntu. For me, the best choice is Sound Juicer because of it’s filename flexibility and ability to deal with compilations. Setting it all up is also very simple. Only two packages are required from the repository. They can be installed with the following [...]
Pausing processes in ubuntu
Posted: 6th June 2010 by Tim in UbuntuTags: continue, linux, pause, pid, process, stop, Ubuntu
There are times when you want to pause a process and continue it later. For example, when a process is using all the computer’s resources and you need to access something or execute something else. This can all be done via the kill -STOP and kill -CONT commands. First you need to grap the pid [...]
Checking for empty string in Bash
Posted: 19th May 2010 by Tim in BashTags: Bash, coding, dash, empty, language, linux, null, programming, script, scripting, SET, shell, string, terminal
In Bash you quite often need to check to see if a variable has been set or has a value other than an empty string. This can be done using the -n or -z string comparison operators. The -n operator checks whether the string is not null. Effectively, this will return true for every case [...]
Setting the SMTP port number in Evolution
Posted: 3rd May 2010 by Tim in UbuntuTags: client, email, evolution, form, gnome, linux, mail, port, setting, Ubuntu
Some mail servers require you to connect on a certain port. Evolution (the default mail client for the gnome desktop environment) doesn’t have a setting for the server port number. You can set this by adding :[port_no] to the end of the server address. For example, to use the mail server mail.example.com on port 587, [...]
Mounting ISO files in Linux
Posted: 24th April 2010 by Tim in UbuntuTags: CD, disk, DVD, image, iso, linux, mount, Ubuntu, umount
One of the niceties of linux distros like Ubuntu is that you can ‘mount’ ISO files. An ISO file, or ISO image, is an archive of a CD or DVD. By mounting an ISO file, you can read the data as though you inserted the CD into your computer. Ubuntu will even regard it as [...]
Using Vim syntax highlighting on custom file types
Posted: 20th April 2010 by Tim in PostgreSQL, Ubuntu, VimTags: config, highlighting, linux, syntax highlighting, vim
Let’s say you have a file type whose contents are in XML format but have a different file extension such as .tim . If you want to edit these files with Vim with syntax highlighting, simply add the following to ~/.vimrc (affects only your Vim environment) or /etc/vim/vimrc (affects everyone’s Vim environment): au BufNewFile,BufRead *.tim [...]
My first LaTeX document
Posted: 28th February 2010 by Tim in LaTeX, UbuntuTags: command, command line, compile, document, LaTeX, linux, mac, PDF, set up, setup, Ubuntu, windows
The learning curve for LaTeX documents can be a steep one. This step-by-step guide covers installing and setting up the LaTeX environment, and creating and compiling your first document so that you can read and distribute it. Setting up the LaTeX environment A few things need to be installed before we can start creating documents. [...]
Removing directories in CVS
Posted: 21st September 2009 by Tim in Bash, CVSTags: Bash, cvs, delete, directories, files, folders, linux, remove, repository, script, unix, version control, versioning
There is no way to delete a folder in CVS like you can with files. The directories must be kept so that the versioning information relating to the files which used to be in the repository can still be used (ie: you can revert back to a revision when the files still existed). The only [...]
Getting MP3s working on Amarok
Posted: 26th July 2009 by Tim in UbuntuTags: amarok, linux, mp3, music, Ubuntu
Amarok, by default, does not come with the MP3 codecs installed. This is for a variety of reasons that I’m not going to go in to here. To get MP3s working in amarok, or to listen to internet radio, you need to install the libxine1-ffmpeg package. In ubuntu, that means doing the following: sudo apt-get [...]