6

My ls command is aliased to have certain options automatically applied, including --classify (same as -F) Normally this is fine and I don't want to screw around with my .bashrc file.

Just this one time, I want to turn off --classify but don't see how even after reading the info page and some googling. There's no --classify=none or --classify=off or --no-classify or anything else I could guess.

This is on Red Hat linux in a bash shell.

1
  • Check to see if you specified an alias for ls in your .profile ? Perhaps you set alias ls="ls --classify" in there.
    – rlb.usa
    Dec 9, 2010 at 22:36

4 Answers 4

7

You can turn off --classify selectively by using --indicator-style=none:

$ alias  lc='ls --classify --color=auto'
$ lc -ld foo bar baz
drwxr-xr-x 6 user group  4096 2010-07-19 09:09 foo/
-rwxr--r-- 1 user group 19035 2010-09-30 17:39 bar*
-rw-r--r-- 1 user group    26 2010-11-29 00:44 baz
$ lc -ld --indicator-style=none foo bar baz
drwxr-xr-x 6 user group  4096 2010-07-19 09:09 foo
-rwxr--r-- 1 user group 19035 2010-09-30 17:39 bar
-rw-r--r-- 1 user group    26 2010-11-29 00:44 baz
2
  • Where Unix is, there is always a clean solution: Thanks for providing it!
    – Eureka
    Dec 10, 2010 at 17:25
  • Changed this to the best answer, the one true way. The backslash or single-quotes does work, but remove all the options in the alias, some of which I continue to want. This --indicator-style option, assuming I will remember it, neatly turns off just the one thing I want off. Very nice!
    – DarenW
    Dec 17, 2010 at 2:10
8

After defining an alias, it remains possible to ask bash to use the unaliased command when necessary, using one of the following syntaxes:

$ 'ls'
$ \ls 

Others tips (howto remove it, etc) about the alias command are available in the dedicated "alias" Wikipedia article.

2
  • This solves my immediate problem, thanks! But it would still be nice to know how to turn off only one of several options set by the alias.
    – DarenW
    Dec 9, 2010 at 22:58
  • If you know that the ls command is an alias, you can remove unwanted option temporarly by dynamicaly generating the "cleaned" ls command using the return of a sed: $(alias ls | cut -f2 -d'=' | sed 's/-l//') myrep to remove a -l, for example.
    – Eureka
    Dec 10, 2010 at 9:24
1

You can temporarily disable aliases by using a \ with the command.

http://www.cyberciti.biz/faq/bash-shell-temporarily-disable-an-alias/

0

You could re-alias it with whatever options you want, and it would be reset to whatever is in your .bashrc file on your next session.

1
  • I don't want the one-time (or three-time, since I make mistakes) modification to the options to last beyond the immediate use.
    – DarenW
    Dec 17, 2010 at 2:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .