Issues with setting Aliases


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issues with setting Aliases
# 8  
Old 02-08-2016
By default, webminal don't set "rm -i" as an alias to "rm" . You can verify this command
Code:
alias | grep "rm"

Above command won't give any alias. As other members mentioned, to set alias do:

Code:
alias rm="rm -i"

Then verify the alias:
Code:
alias | grep "rm"

Now create and delete a file:

Code:
touch a
rm a

This will be interactive delete.

If you want to add this alias to your session. Then edit your ".bash_profile" with above alias.

PS: I'm part of Webminal team, logged in to answer this question Smilie
# 9  
Old 02-08-2016
Quote:
Originally Posted by mohtashims
.
.
.
So the point is rm -rf does not prompt for confirmation while rm -r works and asks for confirmation. Also rm -irf also works.

Can anyone now explain why is this so and how to fix so that "-i" flag works with "-f" flag ?
man rm:
Quote:
-f, --force
ignore nonexistent files and arguments, never prompt

-i prompt before every removal
# 10  
Old 02-08-2016
Hi motashims,

I'm not entirely sure where the rm -if requirement came from, it wasn't here at the beginning of the thread.

But as RudiC says they are mutually exclusive, so can't be used together.

Regards

Gull04
# 11  
Old 02-08-2016
Linux

I dont see this resolved as rm -if prefers -i over -f and asks for user confirmation while when i try to do the same thing by setting alias rm='rm -i' and then rm -f then it does not prefer -i over -f and does not ask for user confirmation which is strange / unexplained.

I take your word that -i and -f should not be used together but if used together why would the behaviour of what is being prefered change when using and not using aliases ?

Note: i m using single qoutes for setting alias and not double quotes. Could that be a problem ?

I will need another 8 hrs before i can paste the output from the terminal. But like i said you can test this issue yrself by registering and loggin to the online terminal -> Join
# 12  
Old 02-08-2016
Hi,

It would probably be best if you were to read this.

Regards

Gull04
This User Gave Thanks to gull04 For This Post:
# 13  
Old 02-08-2016
Quote:
Originally Posted by mohtashims
I dont see this resolved as rm -if prefers -i over -f .
.
.
I can't confirm this claim; tested on Linux and FreeBSD - no confirmation if -f is present, neither when using the alias nor stating the -i explicitly.

---------- Post updated at 14:52 ---------- Previous update was at 14:50 ----------

Mayhap lakshmipathi has more insight?
# 14  
Old 02-08-2016
According to the standards, if rm is invoked with both -i and -f, the last one of those two options specified takes effect and the other option will be ignored. So:
Code:
rm -if other_options operands

should be treated exactly the same as:
Code:
rm -f other_options operands

and:
Code:
rm -fi other_options operands

and:
Code:
rm -f -i -f -ififif -i other_options operands

should be treated exactly the same as:
Code:
rm -i other_options operands

One of the reasons the standards require this is to allow a user to override one of these options set by an alias by just adding the desired option as an option when the alias is invoked.

I make no claims as to whether or not the version of rm you are using conforms to the standards.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Proxy Server

Samba on AIX, issues setting read-only flag on files?

Hello, I am having issues setting the "read-only" flag via Windows Explorer on my AIX Samba share... I have on my AIX 7.1 system installed Samba 3.6.24 and configured, joined to our Windows domain successfully. The samba binaries I got from perzl.org/aix In my smb.conf I have... ... (1 Reply)
Discussion started by: c3rb3rus
1 Replies

2. Solaris

Is there a difference between setting a user as nologin and setting it as a role?

Trying to figure out the best method of security for oracle user accounts. In Solaris 10 they are set as regular users but have nologin set forcing the dev's to login as themselves and then su to the oracle users. In Solaris11 we have the option of making it a role because RBAC is enabled but... (1 Reply)
Discussion started by: os2mac
1 Replies

3. UNIX for Advanced & Expert Users

Issues in setting up remote syslogging

Hello, I am using Ubuntu Linux and having problems in setting up remote syslogging. Appreciate your help on this. On the server unix host, I have made following changes. uncommented following lines in /etc/rsyslog.conf $ModLoad imudp $UDPServerRun 514 Now i am trying to run rsyslog in... (0 Replies)
Discussion started by: ravi.videla
0 Replies

4. Solaris

Help with beginner issues setting up ZFS??

Hi, I'm new to Solaris 11. The goal is to set up a ZFS raid-Z2 NAS. These are the instructions I've been trying to follow, with no luck: "Setting Up an OpenSolaris NAS Box: Father-Son Bonding" (not allowed to post URL) Issues: 1) Root access is evidently required but I don't... (8 Replies)
Discussion started by: lakedude
8 Replies

5. UNIX for Dummies Questions & Answers

Setting aliases

How come if I set an alias as such: alias dt 'date "+%Y-%m-%d %H:%M:%S"' it will work as intended, ie the command 'dt' does prompt the date and time, but not when invoked through a script as such: #!/bin/sh alias dt 'date "+%Y-%m-%d %H:%M:%S"' The OS is FreeBSD 7.1. Thanks in advance (4 Replies)
Discussion started by: figaro
4 Replies

6. Shell Programming and Scripting

etc aliases

Hello: i have several server with own etc aliases. right now i want to combine it all into a general etc aliases in a new freebsd server. cause it consist hundred thousand of record user inside how to make a shell script to combine it or configure it. all etc aliases record example: ... (0 Replies)
Discussion started by: peterLfs
0 Replies

7. UNIX for Dummies Questions & Answers

aliases

Is there a way to view what aliases are running on a given session? (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies

8. Programming

aliases

Hi. I have a C program that is using the **environ pointer and I am trying to set up aliases for a system("/bin/ksh") call. This works for other environment variables but not for the aliases. Does anyone know if this can be done? Thanks ahead of time. (1 Reply)
Discussion started by: mluey61
1 Replies
Login or Register to Ask a Question