Bash coloring on a script output...
I am using Debian 7.
When I type a command from the terminal, ex. "ls -lha", I get the output colored correctly, relative to my .bashrc file. However, when I use the same command from a bash script such as: #!/bin/bash ls -lha I get no color on the output... Does anyone have an idea why this is so? I connected also connected via ssh, but I don't think that is relevant. I find coloring of folders very useful, and would love to have this. Thanks in advance :) |
you need to check how ls works. Probably it is an alias set in ~/.bashrc therefore this alias will not work in a shell script.
|
Exactly
Running "cat ~/.bashrc | grep ls" returned:
alias ls='ls --color=auto' #among other things I added "--color=auto" to the end of the command on my script and now it works. Thank you very much for your reply, still trying to grasp all this... An ex Windows user. :) |
Btw, what do you think is better, using aliases vs adding a folder to $PATH with bash scripts for similar things?
|
glad to help you
grep ls ~/.bashrc would be enough, without cat (if you really want say thanks just press yes) |
Quote:
|
Quote:
Quote:
|
Will do, thanks for more input pan64.
Randicus, I appreciate the correction, we need to try to be exact when speaking... :) |
Quote:
Quote:
|
*Randicus Draco Albus, sorry mate. :D
|
I almost wish you hadn't said this ...
Quote:
I think I've almost never pointed it out, but I do ALWAYS say 'dir' in my answers, even if the qn uses 'folder' :) |
Quote:
Code:
alias ls Code:
type ls Have a great day! |
Quote:
|
Saves me doing it then haha :)
|
Quote:
"directory" is longer to say (and type!) than "folder" though... |
All times are GMT -5. The time now is 05:40 PM. |