- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: alias command
Operating System - HP-UX
1752653
Members
5715
Online
108788
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-1999 06:21 AM
тАО11-17-1999 06:21 AM
alias command
I'm trying to create an alias that will list the files in a directory when you
cd to it. I have used the command
alias cd="cd \!* ; ls"
on other systems. But the HP I'm using doesn't seem to recognize the \!* as a
way to imput characters typed in as arguments in the command line. Do I just
have a syntax error or is this not supported. I cann't find it referenced in
any of my documentation.
I'm running 10.20, Korn shell.
cd to it. I have used the command
alias cd="cd \!* ; ls"
on other systems. But the HP I'm using doesn't seem to recognize the \!* as a
way to imput characters typed in as arguments in the command line. Do I just
have a syntax error or is this not supported. I cann't find it referenced in
any of my documentation.
I'm running 10.20, Korn shell.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-1999 07:24 AM
тАО11-17-1999 07:24 AM
Re: alias command
You may find that you used
alias cd "cd \!* ; ls"
on csh/tcsh or a variant if you are using Ksh try something like the following
alias cd="cd $1; ls"
as "cd" only gets one ARG passed to it you should be safe with the $1.
alias cd "cd \!* ; ls"
on csh/tcsh or a variant if you are using Ksh try something like the following
alias cd="cd $1; ls"
as "cd" only gets one ARG passed to it you should be safe with the $1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-1999 07:59 AM
тАО11-17-1999 07:59 AM
Re: alias command
Anthony's suggestion is a good one at first glance, but unfortunately this
doesn't work :) The $1 variable is not set when the alias command is executed,
so you end up with cd being aliased to "cd ; ls". This will cause any cd
command to jump to your home directory and then do an ls. The Korn shell
doesn't give you any warning that this won't work, but the Posix shell does by
reporting "sh: 1: Parameter not set."
The only way I know to do what is wanted here is to use a function. Just add
the following to your .kshrc or other shell startup script. Keep in mind that
if you want it to happen in your CDE terminal windows, you'll need to set CDE
up to source your regular profiles, or ad these lines to your .dtprofile:
function cdl
{
cd $1
ls
}
alias cd=cdl
This will create the cdl function, which will do whatever is inside the braces.
Make sure you put the alias command after the function. If you put it first,
it runs into a loop of some sort and doesn't work (because cd = cdl before the
function uses it I guess).
The only problem with this simple of a function is that if you give it an
invalid directory, it will give an error and then list the current directory,
often scrolling the error off the screen. You may want to add some error
checking to your function.
doesn't work :) The $1 variable is not set when the alias command is executed,
so you end up with cd being aliased to "cd ; ls". This will cause any cd
command to jump to your home directory and then do an ls. The Korn shell
doesn't give you any warning that this won't work, but the Posix shell does by
reporting "sh: 1: Parameter not set."
The only way I know to do what is wanted here is to use a function. Just add
the following to your .kshrc or other shell startup script. Keep in mind that
if you want it to happen in your CDE terminal windows, you'll need to set CDE
up to source your regular profiles, or ad these lines to your .dtprofile:
function cdl
{
cd $1
ls
}
alias cd=cdl
This will create the cdl function, which will do whatever is inside the braces.
Make sure you put the alias command after the function. If you put it first,
it runs into a loop of some sort and doesn't work (because cd = cdl before the
function uses it I guess).
The only problem with this simple of a function is that if you give it an
invalid directory, it will give an error and then list the current directory,
often scrolling the error off the screen. You may want to add some error
checking to your function.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP