LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-10-2014, 03:06 PM   #1
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 231

Rep: Reputation: 5
Default answer


I have this alias:

alias rm='rm -i'

and I would like for it to accept y upon just hitting enter.

Thanks.
 
Old 07-10-2014, 03:10 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,774
Blog Entries: 1

Rep: Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339
You want it to default to 'y'? You'll have to change the code and recompile it then.
 
Old 07-10-2014, 03:13 PM   #3
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 231

Original Poster
Rep: Reputation: 5
Thanks. I have seen programs ask question during installs and I was under the false impression that there was some way of doing this.
 
Old 07-10-2014, 03:39 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,774
Blog Entries: 1

Rep: Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339
Well,.. if you dont want to press enter everytime, but want to auto-yes it you can always pipe an echo to it:

Code:
echo y|rm -i whatever
or use yes

Code:
yes | rm -i whatever
But having it default to yes so you can press enter isn't possible AFAIK.
 
Old 07-11-2014, 07:42 PM   #5
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 808

Rep: Reputation: 216Reputation: 216Reputation: 216
You could put a small script into your bin directory that does what you want. Then point your alias to the script.
The script could look similar to this:
Code:
#!/bin/bash
for i in $*; do  
        read -r -p "Delete $i? [Y/n] " userinput
        case $userinput in
            [nN][oO]|[nN]) 
                echo "Not deleted"
                ;;  
            *)  
                rm -f $i               # Add the -r flag here if you also want to be able to delete directories
                echo "Deleted"
                ;;  
        esac
done
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I can not find answer of this question. Please post helpful answer. pritammt Linux - Newbie 8 05-30-2014 06:43 AM
[SOLVED] Xubuntu 14.04 - Default panel removed. I Can't return it back to default mode. Jader Linux - Newbie 3 05-16-2014 11:50 AM
LXer: Thunderbird Made Default In Ubuntu 11.10, Final Default Email Client Decision Not Yet Taken LXer Syndicated Linux News 0 07-01-2011 08:10 PM
Details about default web Browser & default Email client sudhasmyle Linux - Software 4 06-15-2006 12:45 PM


All times are GMT -5. The time now is 02:00 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration