Posted by Christian Ashby on April 28, 2010
If you are writing a BASH script which searches for a file pattern in a folder using this syntax:
[-f {pattern}]
Instead, use the following syntax:
files=$(ls {pattern} 2> /dev/null | wc -l)
if [ "$files" != "0" ]
This can be replaced with a similar command using find if required.
Tags: bash, debian, linux, ubuntu
Posted in Linux | No Comments »
Posted by Christian Ashby on April 19, 2010
For those using Debian or Ubuntu Linux, there are situations where the package management system can leave files open if a certain package fails, or if you cancel the installation using CTRL+C, you may see the following error when you try another package installation:
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
Using the following command will tell you what’s using it:
fuser -v /var/cache/debconf/config.dat
This will give you the process ID in the right-hand column. You can then use kill {process ID} to remove this process and re run your apt-get command.
Tags: debian, linux, ubuntu
Posted in Linux | No Comments »