Review your favorite Linux distribution.
Go Back > Blogs
User Name



"Wait until a process ends, a download ends, or a file conversion ends, then do X"

Posted 08-30-2011 at 03:06 PM by the dsc (linux-related notes)
Updated 08-30-2011 at 09:41 PM by the dsc (a small improvement)

Sometimes you want the computer to shut down after you've finished downloading something or converting some large file into some other format, but you want to go out or go to sleep instead of waiting and checking for it yourself.

For these situations I've come up with two tiny scripts. The first one waits until a file hasn't changed its size on three consecutive intervals of twenty seconds:

a=0 ; file="$1" ; if [ -f "$file.part" ] ; then file="$file.part"
Posted in Uncategorized
Views 898 Comments 0 the dsc is offline

How hard could it be? A login manager in BASH

Posted 07-11-2011 at 08:34 PM by William (Dthdealer) (Whaling the FOSS)

As I have previously elaborated, I hat the Gnome Login Manager. To summarise: it is bulky and slow.

I am currently using SLim as my login manager, for it is fast and very customisable. It however lacks a few features I want:
  1. Render of the date and time
  2. An easy way to receive a list of configured commands to for example, turn the computer off ( from now written as 'power commands' )
  3. UI elements to allow the user to turn the computer off without having to first login

Views 2289 Comments 0 William (Dthdealer) is offline

Getting Absolute Paths of UNIX Directories and Filenames in Shell Scripts

Posted 07-08-2011 at 03:05 AM by konsolebox
Updated 07-17-2011 at 09:11 AM by konsolebox
Tags bash, ksh, script, shell, zsh

This post is a compilation of the function getabspath() for different shells that can be used to get the absolute form of a path. The function accepts an argument path then returns the absolute form of it to the variable $__.

bash (3.0 and newer only)
function getabspath {
	local -a T1 T2
	local -i I=0
	local IFS=/ A

	case "$1" in
		read -r -a T1 <<< "$1"
Senior Member
Posted in Howtos
Views 2102 Comments 0 konsolebox is offline

If condition "if condition ... if condition"

Posted 08-28-2010 at 06:26 PM by the dsc (linux-related notes)
Updated 08-28-2010 at 06:28 PM by the dsc

If you want to have a script that would do something if either one of two consequences is true, a simple way to do that would be:

if [ condition 1 ] || [ condition 2 ] ; then
if [ condition 1 ] ; then
consequences for condition 1
if [ condition 2 ] ; then
consequences for condition 2
consequences of either one, but happens only once, not twice
You check if either one is true, when "||"...
Posted in Uncategorized
Views 748 Comments 0 the dsc is offline

Shortest command to calculate the sum of a column of output

Posted 06-02-2010 at 06:27 AM by bittner (Notes on Linux)

I had to calculate the Installed-Size for a .deb control file recently. Here is the solution I came up with:

dpkg-deb -c mypackage.deb | sed -e 's/.*root\s*//' -e 's/\s*2010-.*$//' | xargs | tr ' ' + | bc
What it does? The code tries to construct a calculation string and feeds it to the command line calculator bc as follows:
  1. use dpkg-deb to get the file size information out of the Debian package
  2. sed away all characters before and after the
LQ Newbie
Posted in Uncategorized
Views 4787 Comments 2 bittner is offline


All times are GMT -5. The time now is 11:06 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration