LinuxQuestions.org
Help answer threads with 0 replies.
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 03-09-2005, 06:03 AM   #1
learnfast
Member
 
Registered: Mar 2005
Location: berlin
Distribution: Redhat 9, Fedora 3
Posts: 70

Rep: Reputation: 15
how to map "dir" to "ls -al | more"?


how can I map a command, e.g. when I type "dir" I want it to execute "ls -al | more"

"dir" already executes "ls" but the listing is not in color (I don't understand that either)

i'm using red hat 9.0 in text mode (init 3)

thanks
 
Old 03-09-2005, 06:25 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

alias dir='ls -al | more'

Take a look at the bash manpage (section: aliases).

Hope this helps.
 
Old 03-09-2005, 06:31 AM   #3
Engmar
Member
 
Registered: Oct 2003
Location: The Forest
Distribution: Ubuntu, LFS, DSL
Posts: 127

Rep: Reputation: 16
Try
Code:
alias dir="ls -al --color=always | more"
 
Old 03-09-2005, 06:31 AM   #4
learnfast
Member
 
Registered: Mar 2005
Location: berlin
Distribution: Redhat 9, Fedora 3
Posts: 70

Original Poster
Rep: Reputation: 15
excellent, that's exactly what I was looking for
and how can I save this alias so that it is available when I boot up / log in again?

thanks
 
Old 03-09-2005, 06:37 AM   #5
learnfast
Member
 
Registered: Mar 2005
Location: berlin
Distribution: Redhat 9, Fedora 3
Posts: 70

Original Poster
Rep: Reputation: 15
where are the colors defined for the --color parameter?
directories seem to be dark blue, "mount" is white on red, some green, some aqua...
I checked "man ls" but it didn't tell me

thanks
 
Old 03-09-2005, 06:48 AM   #6
Hammett
Senior Member
 
Registered: Aug 2003
Location: Barcelona, Catalunya
Distribution: Gentoo
Posts: 1,072

Rep: Reputation: 59
To be able to use it everytime you boot the PC, add the aliast to your .bashrc file, for the colors, I don't know exactly what you want. If you don't want colors at all, add to the alias --color=none.
If you want to change colors, you must edit your /etc/DIR_COLORS file and put the colors you wish there for every time of archive.
 
Old 03-09-2005, 07:05 AM   #7
learnfast
Member
 
Registered: Mar 2005
Location: berlin
Distribution: Redhat 9, Fedora 3
Posts: 70

Original Poster
Rep: Reputation: 15
how can I make an alias which accepts a parameter, e.g. as in msdos the %1 %2
so that I can say "dir b*"
something like this:
dir="ls -al --color=always %1 | more"
 
Old 03-09-2005, 07:15 AM   #8
Hammett
Senior Member
 
Registered: Aug 2003
Location: Barcelona, Catalunya
Distribution: Gentoo
Posts: 1,072

Rep: Reputation: 59
Add to the alais $1 so you end up with dir="ls -al --color=always $1 | more".
Note that you have to modify the alias if you want more parameters ($2 $3 and so on).
If you plan to use multiple parameters, I suggest you to make the alias as dir="ls -al --color=always" and add the | more afterwards if needed. as ls will take all the parameters you put as they are, you don't need to specify the $1 and more. Even though I can't imagine doing an ls with more that one parameter....
 
Old 03-09-2005, 07:23 AM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Don't know if any of you noticed/know this, but dir is an excisting command (/usr/bin/dir).

Creating a alias/variable could give you unexpected outcome.

Just a 'heads-up'.
 
Old 03-09-2005, 07:27 AM   #10
learnfast
Member
 
Registered: Mar 2005
Location: berlin
Distribution: Redhat 9, Fedora 3
Posts: 70

Original Poster
Rep: Reputation: 15
I got this to work:
dir="ls -al --color=always $1"

but this will not work:
dir="ls -al --color=always $1 | more"

does anyone know how to put the "more" command in the alias itself (I don't know why I would ever want ALL the files to just scroll on by and I only see the last ones, especially in text mode where I can't scroll back up)

thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
what is "sticky bit mode" , "SUID" , "SGID" augustus123 Linux - General 10 08-03-2012 04:40 AM
Telling people to use "Google," to "RTFM," or "Use the search feature" Ausar General 77 03-21-2010 11:26 AM
"Xlib: extension "XFree86-DRI" missing on display ":0.0"." zaps Linux - Games 9 05-14-2007 03:07 PM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 02:32 PM

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

All times are GMT -5. The time now is 04:25 PM.

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