.bashrc question re: rm -i & ls --colors


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers .bashrc question re: rm -i & ls --colors
# 8  
Old 04-21-2008
era -- would I add this to my .bashrc file or a separate script by itself?

rm () {
local ask
ask="-i"
case $# in 1)
case $1 in your|excluded|files) ask= ;; esac ;;
esac
/bin/rm $ask "$@"
}
# 9  
Old 04-21-2008
You could also use: # \rm [files]
When you wanted to delete the files that shouldn't be asked for deletion, it will omit the possible alias, and just use the default "rm" behaviour.
# 10  
Old 04-21-2008
kthatch: you would add that to your .bashrc instead of the alias you have there now.

You could also get in the habit of using "rm -f" to suppress the question.
# 11  
Old 04-21-2008
Thank you ALL for responding!

Pupp/Redhead --- I added another alias to my .bashrc (alias wlt='\rm -r work log tmp') and WHALAH! -- it overroad the previous alias rm='rm -r alias' entry and removed my 3 files without prompting --- Thank you!

Era --- I also, tried your soluiton. I added that to my .bashrc and it still prompted me to "examine files in directory ...". and so did using the -f option.
# 12  
Old 04-21-2008
era --- as for my colors, here is the results to your question:

# which ls
/usr/bin/ls

# type -all ls
ls is /usr/bin/ls
# 13  
Old 04-21-2008
You were supposed to edit the rm() function, not copy / paste smack dab, as at the time I wrote it I didn't know the names of the files you wanted to exclude. Change "your|excluded|files" to "log|work|tmp".

When you type ls you get /usr/bin/ls instead of /usr/local/bin/ls, which is apparently the version with color support. Like indicated previously, setting your alias to point explicitly to /usr/local/bin/ls will enable color support and you should no longer need to use the full path.

Last edited by era; 04-21-2008 at 04:53 PM.. Reason: Respond to ls question, too
# 14  
Old 04-21-2008
Yes, I did that --- sorry I did not clarify.

rm () {
local ask
ask="-i"
case $# in 1)
case $1 in work|log|tmp) ask= ;; esac ;;
esac
/bin/rm $ask "$@"
}
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remoting sudo commands & bypassing bashrc

What I want to do is not unique, except that our environment has a twist. I want to ssh to a remote server and issue a sudo command to run a script. This isn't working, but you'll get the gist.# ssh remotehost sudo -i -u oracle script.bashThe sudo to oracle is fine. The script.bash sets up the... (4 Replies)
Discussion started by: JustaDude
4 Replies

2. Shell Programming and Scripting

awk Help: quick and easy question may be: How to use &&

Hi Guru's. I am trying to use to check if $5 is greater than 80 & if not 100, then to print $0 : awk '{ if ($5>80) && if ($5 != 100) print $0} But getting error: >bdf1|sed 's/%//g'|awk '{ if ($5>80) && if ($5 != 100) print $0}' syntax error The source line is 1. The error... (6 Replies)
Discussion started by: rveri
6 Replies

3. Programming

Quick question about '_&'

I've seen in other programmers code the use of '_&' as a line separator. I am trying to find in my C++ reference manual some pages dedicated to an explanation of the use of this '_&' but I don't know what it is called. I only know it is a "line separator" or "line break" of some sort which is... (0 Replies)
Discussion started by: sepoto
0 Replies

4. Shell Programming and Scripting

perl newbie . &&..programming newbie (question 2)

Hello everyone, I am having to do a lot of perl scripting these days and I am learning a lot. I have this problem I want to move files from a folder and all its sub folders to one parent folder, they are all .gz files.. there is folder1\folder2\*.gz and there are about 50 folders... (1 Reply)
Discussion started by: xytiz
1 Replies

5. UNIX for Dummies Questions & Answers

Question on x-window & which Linux to go with

Hi, Currently in my company, we are using Windows 2003 server and Exceed. Team from India can connect to the Windows 2003 server and start Exceed to run their UNIX application. The application is GUI based. As you know, Windows 2003 only allows two connection at any time. so I want to... (3 Replies)
Discussion started by: samnyc
3 Replies

6. UNIX for Dummies Questions & Answers

.bashrc question

Hi, I was instructed to find all the .bashrc files on my system, that MODIFY the PS1 varaible. here is what i've come up with so far: ls / .bashrc -print woo. But thats not all. I need to display the full file name ( Including the full path ) and protection. - I can display... (4 Replies)
Discussion started by: oxoxo
4 Replies

7. Shell Programming and Scripting

creating & sending formatted (with bolds & colors) CSV

Hi , I have a situation. Need is to create & send a formatted file with header in BOLD & colored & some sequel results as a content. I know echo -e \033 command, but its scope is limited in PUTTY. How to retain the formatting out of Putty; say after someone opens a email attachment... (2 Replies)
Discussion started by: infaWorld
2 Replies

8. Linux

xterm font colors - configuration question?

When I telnet (ssh) over to my Fedora system, I find the colors horrible. For instance, regular files are white text, which is fine, but directories show up as dark blue which is virtually invisible against the black background). Additionally, when using vi, I find the colors great doing perl... (3 Replies)
Discussion started by: ripley
3 Replies

9. UNIX for Dummies Questions & Answers

dirs & colors

hi @all question from an absolute beginner: I want directory listings to be displayed with different colors... what do I have to do and where can I find the settings? thx (4 Replies)
Discussion started by: tk876
4 Replies

10. UNIX for Dummies Questions & Answers

And(&&) Question

Hi, for example in this script I want both of these files to be listed with my "ls" command but it won't work, is there a way to do it like this I've tried &, ||, |, etc. This seems so simple but I can't figure it out. I thought with "&&" it would work but I was wrong! #!/usr/ksh touch... (7 Replies)
Discussion started by: Astudent
7 Replies
Login or Register to Ask a Question