LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-10-2012, 11:41 PM   #1
ynnhoj67
LQ Newbie
 
Registered: Jan 2012
Posts: 5

Rep: Reputation: Disabled
Question alias rm='rm.sh isn't working in my ubuntu 12.04


Can anyone help me with my issue in ubuntu 12.04, i'm new to linux and just trying to play around with it.
I made a rm.sh basically it will move files to a trash directory instead of delete it.
and i also know
Code:
alias rm='rm.sh
will not able to execute rm.sh after reboot.
therefore i made another shell script(modify.sh) and saved under /etc/rc2.d, was hoping every time it reboots and will automatically alias rm.sh. But after i rebooted and it still not working, then i deleted modify.sh from /etc/rc2.d
and here is the new issue, now whenever i tried to do
Code:
alias rm='rm.sh
it displays
Code:
root@j-desktop:/bin# alias rm='rm.sh
> _
and alias is no longer working anymore. what is the problem and how to resolve it?
code for modify.sh is:
Code:
alias rm='/bin/rm.sh

any help would be appreciated.
Thanks
 
Old 05-11-2012, 12:01 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Try the last line but add the trailing single quote.

There is libtrash to do what you doing, but at the system call level.

Also consider defining a function instead of a script.
 
Old 05-11-2012, 09:10 AM   #3
ynnhoj67
LQ Newbie
 
Registered: Jan 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jschiwal View Post
Try the last line but add the trailing single quote.

There is libtrash to do what you doing, but at the system call level.

Also consider defining a function instead of a script.
Thanks jschiwal, by defining a function is that means in my modify.sh should be a function call right?
 
Old 05-11-2012, 09:29 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Aliases are for use in an interactive shell after login so are set in the shell initialisation files. For bash that's normally /etc/profile (global), ~/.bash_profile and ~/.bashrc. Full information on the bash startup files here.

Setting aliases in the boot scripts (/etc/rc2.d and similar) is not effective.

When you define an alias the the quotes must be terminated (the OP shows an alias string with an opening ' but no closing ').
 
Old 05-11-2012, 10:06 AM   #5
ynnhoj67
LQ Newbie
 
Registered: Jan 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
Aliases are for use in an interactive shell after login so are set in the shell initialisation files. For bash that's normally /etc/profile (global), ~/.bash_profile and ~/.bashrc. Full information on the bash startup files here.

Setting aliases in the boot scripts (/etc/rc2.d and similar) is not effective.

When you define an alias the the quotes must be terminated (the OP shows an alias string with an opening ' but no closing ').
Thanks catkin.
i'll need to look into bash startup files
 
Old 05-11-2012, 05:39 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You can define a function in .profile. A function works better than an alias for commands that take arguments, or when you need to perform a test on the arguments. In your example, if you use an alias for the rm command, you need to use 'rm -t ~/.trash/'. If it weren't for the -t argument, you wouldn't be able to alias the command, as the source file arguments come at the end of the file.

Using libtrash instead, files deleted in the desktop, or by a program would also be trashed instead of deleted.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
after installing ubuntu 10.04 on Eeepc 1000HE netbook, wifi isn't working.what to do? MAROMAR Linux - Wireless Networking 3 08-08-2011 02:09 AM
Ubuntu isn't working and I can't boot from disk chinaexpress Linux - Desktop 1 06-03-2010 01:01 AM
Alias not working tofani Linux - General 7 11-29-2005 03:43 AM
Apache Alias isn't working soren625 Linux - Software 3 03-07-2005 04:46 PM
My USB isn't working in Ubuntu... SonoranFun Linux - Hardware 1 12-03-2004 06:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:59 AM.

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