LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 02:06 PM   #1
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 258

Rep: Reputation: Disabled
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, 02:10 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

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

Original Poster
Rep: Reputation: Disabled
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, 02:39 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
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, 06:42 PM   #5
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,016

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
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



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 05: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 10: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 07:10 PM
Details about default web Browser & default Email client sudhasmyle Linux - Software 4 06-15-2006 11:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:26 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