- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Alias question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
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
Community
Resources
Forums
Blogs
- 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
06-09-2010 08:19 PM
06-09-2010 08:19 PM
We can set alias by:
# alias ls='ls -al'
But, what if I want to set an alias for:
"vgdisplay -v" to "abc"
So, I can run:
# abc vg01
and get results for "vgdisplay -v vg01".
Is that possible?
Thanks..
Solved! Go to Solution.
- Tags:
- alias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2010 09:04 PM
06-09-2010 09:04 PM
Re: Alias question
# alias abc='vgdisplay -v'
[rx260-13]/
# abc vg00
--- Volume groups ---
VG Name /dev/vg00
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 8
Open LV 8
Max PV 16
Cur PV 1
Act PV 1
Max PE per PV 4356
VGDA 2
PE Size (Mbytes) 32
Total PE 4346
Alloc PE
Regards,
Sooraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2010 10:30 PM
06-09-2010 10:30 PM
Re: Alias question
I guess I have put the question in a wrong way. Let me give an example, how can I put alias for 'vgdisplay -v vg01' for 'vgdisplay -v vg02', so that when I execute the command:
# vgdisplay -v vg01
We get the result for 'vgdisplay -v vg02'....something like:
# alias 'vgdisplay -v vg01'='vgdisplay -v vg02' <<<< well this do not work :-(
So, I am looking on how to use multiple words on both sides of '=' while using alias.
May be it is more clear this time :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2010 12:23 AM
06-10-2010 12:23 AM
Re: Alias question
You can not. You should give up on aliases and use functions or scripts:
># vgdisplay -v vg01 # We get the result for 'vgdisplay -v vg02'
vgdisplay:
#!/usr/bin/ksh
if [ X"$1" = "X-v" -a X"$2" = Xvg01 ]; then
/usr/sbin/vgdisplay -v vg02
else
/usr/sbin/vgdisplay "$@"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2010 12:49 AM
06-10-2010 12:49 AM
Solutionin fact you need to use a function and not an alias
function vgdisplay {
if [ $# = 0 ]
then
/usr/sbin/vgdisplay
return $?
fi
set -A x -- "$@"
typeset -i xs=${#x[*]}-1
target="${x[xs]}"
if [ "${x[xs]}" = vg01 ]
then
x[xs]=vg00
fi
/usr/sbin/vgdisplay "${x[@]}"
return $?
}