View Full Version : Help with my shell script?
jordanae
October 28th, 2009, 09:48 PM
I'm not sure if this is the right place for this, but here it goes:
I just wrote a shell script to run to clean up my desktop. It's extremely simple:
mv /home/jordan/Desktop/gnome-terminal.desktop /home/jordan/clean_up/gnome-terminal.desktop
rm /home/jordan/Desktop/*
mv /home/jordan/clean_up/gnome-terminal.desktop /home/jordan/Desktop/gnome-terminal.desktop
It works, but whenever I run the script the terminal icon wont show up on the desktop. I ran an ls -l on my desktop and it showed up, and when I logged out and back in again it showed up. Is there a way to fix this?
-Sparx-
October 28th, 2009, 10:24 PM
You can try to reload the desktop (folder).
When you have the desktop in front of you hit "C-r" (ctrl and the 'r' button). Just as you would refreshing a webpage in firefox.
sisco311
October 28th, 2009, 10:28 PM
Assuming that it's a bash script you can use !(filename) to match anything except filename.
i.e.
shopt -s extglob
rm ~/Desktop/!(gnome-terminal.desktop)
man bash | less --pattern\="extglob"
jordanae
October 29th, 2009, 02:49 AM
Assuming that it's a bash script you can use !(filename) to match anything except filename.
i.e.
shopt -s extglob
rm ~/Desktop/!(gnome-terminal.desktop)
man bash | less --pattern\="extglob"
Thanks a lot. But what does the shopt command do? I'm on my phone right now so I can't run a man or info command :/
yknivag
October 29th, 2009, 02:58 AM
Thanks a lot. But what does the shopt command do? I'm on my phone right now so I can't run a man or info command :/
shopt [-pqsu] [-o] [optname ...]
Toggle the values of variables controlling optional shell behavior. With no options, or with the -p option, a list of all settable options is displayed, with an indication of whether or not each is set. The -p option causes output to be displayed in a form that may be reused as input. Other options have the following meanings:<snip>
Taken from http://www.linuxmanpages.com/man1/shopt.1.php
Essentially -s causes the extglobs option to be set in the shell behaviour options. extglobs allows the use of globs (such as !) in filenames.
phrostbyte
October 29th, 2009, 04:28 AM
You might need to do this:
nautilus --restart
geirha
October 29th, 2009, 09:54 AM
This covers mostly the same as the man-page on globs http://mywiki.wooledge.org/glob, but has some examples of use too.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.