display text file within an editor on whatever workspace is in front of you

env DISPLAY=:0 /usr/bin/gedit ~/df.txt && wmctl -a gedit
Usage example: display output of a command running in the background at desired time The example in details: report disk quotas and that backup process will start soon In my /etc/crontab file I added following four lines for weekly automatic incremental backup: . 52 13 * * 7 root mount /dev/sda3 /media/da2dc69c-92cc-4249-b2c3-9b00847e7106 . 53 13 * * 7 knoppix5 df -h >~/df.txt . 54 13 * * 7 knoppix5 env DISPLAY=:0 /usr/bin/gedit ~/df.txt && wmctl -a gedit . 55 13 * * 7 root /home/knoppix5/rdiff-backup.sh . line one: as root mount media for backup on Sunday 13:52 line two: as user knoppix5 write out to text file in home directory the free space of all mounted disks on Sunday 13:53 line three: in front of you open and display a very simple text editor (I prefer gedit) with content of previously reported disk usage at Sunday 13:54 wmctl -a gedit means (from the manual): -a Switch to the desktop containing the window , raise the window, and give it focus. line four: as root run incremental backup script rdiff-backup.sh as root on Sunday 13:54 . my rdiff-backup.sh, with root permissions backups in short time (writes only changes from the last backup) the etire linux system (except excluded - i.e. you don't want backup recursively your backup disk), looks like this (Show sample output):
Sample Output
rwxr-xr-x  1 root    root           561 Tra 10 20:59 /home/knoppix5/rdiff-backup.sh
$ cat  /home/knoppix5/rdiff-backup.sh

#uncomment next two lines if you run script manually (not from cron)
#mount /dev/sda3 /media/da2dc69c-92cc-4249-b2c3-9b00847e7106
#sleep 3 

rdiff-backup  --exclude=/run --exclude=/dev  --exclude=/tmp  --exclude=/media --exclude=/mnt --exclude=/proc --exclude=/sys / /media/da2dc69c-92cc-4249-b2c3-9b00847e7106/rdiff-backup &&
sleep 3
umount /media/da2dc69c-92cc-4249-b2c3-9b00847e7106
# Important: never ever lose your thunderbird mail again - run backup script (e)very soon!

By: knoppix5
2015-04-12 13:48:31

What Others Think

Also, gedit can be used in a pipe, (if you only want to read the information once), e.g. df -h | gedit - &
flatcap · 337 weeks ago
I tried. Empty gedit is displayed. Thanks for upvoting!
knoppix5 · 336 weeks and 6 days ago
Hmm... gedit --version gedit - Version 3.14.3
flatcap · 336 weeks and 5 days ago
Oh, I see: . gedit -V gedit - Version 2.30.4 . "This is a new feature in Gedit. It was introduced in the version that came with Gnome 3.0." ( http://stackoverflow.com/questions/3864814/how-to-pipe-program-output-in-an-editor )
knoppix5 · 336 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

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.

Share Your Commands

Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: