![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
General Help All your general support questions for Ubuntu, Kubuntu, Edubuntu and Xubuntu. |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
5 Cups of Ubuntu
![]() Join Date: Jul 2008
Beans: 28
|
Useful Shell Scripts
Hello, these are a collection of shell scripts I have created and found very useful.
install-script - installs a shell script mv $1 /usr/local/sbin/$1 chmod a+rwx /usr/local/sbin/$1 use: install-script file alph - alphabetizes a file cat "$1" | sort > "$1" use: alph file clndir - gets rid of pesky "file~" files rm *~ use: clndir directory/name empty-trash - empties the trash bin rm -rf ~/.local/share/Trash/ use: empty-trash delinux-disk - gets rid of .Trash directories on jump drive sudo mv /media/$1/.* ~/.local/share/Trash/files/ empty-trash use: delinux-disk drive name vidget - downloads youtube videos and names them !IMPORTANT! use the following code before using this script: sudo apt-get youtube-dl youtube-dl http://www.youtube.com/watch?v=$1 mv ~/$1.flv ~/Videos/$2.flv use: vidget video-roster-number desired name for clarification or amendments on any of these just reply to this post. Thanks Guys! Last edited by dennismoore1; October 20th, 2008 at 08:17 PM.. |
|
|
|
|
|
#2 |
|
Ubuntu Extra Shot
![]() Join Date: Jun 2007
Beans: 337
|
Re: Useful Shell Scripts
Here's a useful shell script I use:
Code:
#!/bin/bash /etc/init.d/ntp stop ntpdate ntp.ubuntu.com /etc/init.d ntp start hwclock --systohc |
|
|
|
|
|
#3 |
|
Skinny Soy Caramel Ubuntu
![]() Join Date: May 2008
Beans: 669
Ubuntu 9.04 Jaunty Jackalope
|
Re: Useful Shell Scripts
Good scripts. My only comment is that, in the "empty-trash" script, you only need to remove the Trash folder, and unless there are some files you do not own in your Trash folder, "sudo" is not required. When you next delete a file, the Trash folder is recreated.
__________________
Everything that has a Beginning, has an End
|
|
|
|
|
|
#4 |
|
5 Cups of Ubuntu
![]() Join Date: Jul 2008
Beans: 28
|
Re: Useful Shell Scripts
Could you please clarify WRDN?
I did not quite understand that. I have tinkered with the script quite a bit. And I am the only user on my system so I almost never include security. Of course, I am deffinitly no master. I am open to your suggestions. |
|
|
|
|
|
#5 | |
|
Skinny Soy Caramel Ubuntu
![]() Join Date: May 2008
Beans: 669
Ubuntu 9.04 Jaunty Jackalope
|
Re: Useful Shell Scripts
Quote:
To quote from the original post: Code:
empty-trash - empties the trash bin sudo rm -rf ~/.local/share/Trash/ mkdir ~/.local/share/Trash/ mkdir ~/.local/share/Trash/info mkdir ~/.local/share/Trash/files use: empty-trash Code:
rm -rf ~/.local/share/Trash
__________________
Everything that has a Beginning, has an End
|
|
|
|
|
|
|
#6 |
|
5 Cups of Ubuntu
![]() Join Date: Jul 2008
Beans: 28
|
Re: Useful Shell Scripts
very very true
however, are you sure that when you delete a file the trash bin directories are recreated on their own? |
|
|
|
|
|
#7 |
|
5 Cups of Ubuntu
![]() Join Date: Jul 2008
Beans: 28
|
Re: Useful Shell Scripts
oh yes
it is i just tested it ill make an amendment thank you |
|
|
|
|
|
#8 |
|
Ubuntu Guru
![]() |
Re: Useful Shell Scripts
good start, but can be simplified.
Take a look at pipes and redirects. cat "$1" | sort > "$1" *Note also using quotes " " allows file names with spaces Also you will like this one look at man mkdir mkdir -p ~/.local/share/Trash/{info,files} You should likely use /usr/local/bin for scripts (rather then sbin) Most of these "one liners" can be set as an alias or function in ~/.bashrc
__________________
A person with ubuntu is open and available to others, affirming of others, does not feel threatened that others are able and good, for he or she has a proper self-assurance that comes from knowing that he or she belongs in a greater whole and is diminished when others are humiliated or diminished, when others are tortured or oppressed. ~ Archbishop Desmond Tutu, 1999 ![]() |
|
|
|
|
|
#9 |
|
Fresh Brewed Ubuntu
![]() Join Date: Sep 2007
Location: Masschusetts
Beans: 1,368
Ubuntu 8.04 Hardy Heron
|
Re: Useful Shell Scripts
Use this one twice a day.
Just one a threw together for myself so there isn't much error checking or anything. Simple enough to modify for other systems, PM me with any questions. Could automatically check for a mounted drive easily enough, I just ask the user to remind myself to check, don't need the script to check for me. Code:
#!/bin/ksh # The backup created is of /Users (all users home and shared directories) not # system files. Add any other directories below. # This script will sync the backup located on /Volumes/My_External using # the rsync command with options archive and one file system. begin=no run=0 while [[ $run -eq 0 ]] do echo "Is the drive mounted and ready for the backup to begin?" echo "(yes|no|exit)" read begin if [[ $begin = "yes" ]] then run=1 sudo rsync -ax --delete /Users /Volumes/My_External # -a archive mode (recursive, links, perms, times, groups, owner, devices) # -x one file system # ADD ADDITIONAL DIRECTORIES HERE USING ABOVE RSYNC COMMAND else if [[ $begin = "no" ]] then clear echo "Please Connect and Mount the drive and type yes to continue." else if [[ $begin = "exit" ]] then run=1 clear else echo "Please enter valid input (yes|no|exit)" fi fi fi done
__________________
Registered Linux User: 482377 MacBook (1,1) - OS X Leopard ASUS P5LD2 - Core 2 Duo 3.0GHz - 2GB Corsair RAM - Nvidia 8800GT - Ubuntu 9.04 / Windows 7 Professional |
|
|
|
| Bookmarks |
| Tags |
| shell script useful trash |
| Thread Tools | |
| Display Modes | |
|
|