- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: substituting
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
Discussions
Discussions
Discussions
Forums
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
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-28-2002 05:43 AM
тАО06-28-2002 05:43 AM
Sometime, I will have the following string:
"vgcreate $opstr -p $maxPV -l $maxLV -s $PESize -e $maxPEperPV $vg $dskName"
Also, in some cases, I will need to remove some of the options specified in the above string and have the following format:
vgcreate $opstr -p $maxPV -l $maxLV $vg $dskNam
(no -e $maxPEperPV, -s $PESize)
Do you know how do it?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2002 05:51 AM
тАО06-28-2002 05:51 AM
Re: substituting
what about putting the two commands into a script and give a hard link to that script. ( a second name, same inode number):
vi name1
case $0 in
name1) first_possible_command_line ;;
name2) second_possible_command_line ;;
esac
After this the following command line:
ln name1 name2
That should do it for you!
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2002 05:51 AM
тАО06-28-2002 05:51 AM
Re: substituting
U can use sed command to remove unwanted string. It is like this
#sed 's/-s $PEsize -e $maxPEperPV//g' file
I hope this will do for U.
Best of luck
Shahul
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2002 05:57 AM
тАО06-28-2002 05:57 AM
SolutionThis would remove the portion you don't want:
# sed -e 's/-s $PESize -e $maxPEperPV //'
For instance:
# X='vgcreate $opstr -p $maxPV -l $maxLV -s $PESize -e $maxPEperPV $vg $dskName'
# Y=`echo $X|sed -e 's/-s $PESize -e $maxPEperPV //'`
# echo $Y
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2002 05:57 AM
тАО06-28-2002 05:57 AM
Re: substituting
sorry, i forgot to mention why this works....
$0 stores the name of the command to execute, and you simply check, which name was used when the script was called. If you used name1, the first command line is executed, in your case with all options... If the used name was name2, the alternative command line is executed.
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2002 06:19 AM
тАО06-28-2002 06:19 AM
Re: substituting
One las thing:
how can I remove -e -s but without specifying $PESize, or $MAXPEperPV?
e.g.
remove -s and the next value?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2002 08:23 AM
тАО06-28-2002 08:23 AM
Re: substituting
OK, here's a small script which will do what you want:
#!/usr/bin/sh
echo $1 | awk '{K=split($0,a)
N=1;while (N <= K)
{ if (a[N]=="-s") N=N+2
if (a[N]=="-e") N=N+2
printf "%s ",a[N];N++
}
printf "\n"
}'
exit 0
...pass your command string to this script. If the string contains the '-e' or '-s' option, the next argument is removed, otherwise the command is left intact and re-echoed. If we call the script 'my.sh' you could do this:
# X=`./my.sh 'vgcreate $opstr -p $maxPV -l $maxLV -s $PESize -e $maxPEperPV $vg $dskName'`
# echo $X
...yields:
vgcreate $opstr -p $maxPV -l $maxLV $vg $dskName
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-29-2002 05:07 AM
тАО06-29-2002 05:07 AM
Re: substituting
The script I posted above has one dumb flaw. It assumes that the arguments passed to it are quoted. Replace "$1" with "$@", or use the attachment here (...the Forum mechanics make mince-meat of formatted scripts!).
Thus:
# ./my.sh vgcreate -e 4096 -l 10 -p 50 -s 8 /dev/vg01 /dev/dsk/cXtYdZ
...returns:
vgcreate -l 10 -p 50 /dev/vg01 /dev/dsk/cXtYdZ
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-02-2002 08:04 AM
тАО07-02-2002 08:04 AM
Re: substituting
maxPEperPV=$(...whatever you use now...)
if ( ${maxPEperPV} > 0 )
then
maxPEperPV="-e ${maxPEperPV}"
else
maxPEperPV=""
fi
# do similar ofr PESize, or even leverage
# the above test
.
.
.
vgcreate $opstr -p $maxPV -l $maxLV $PESize $maxPEperPV $vg $dskName
If PESize and maxPEperPV were specified, they will be used, if not, they interpret to nothing.
-dlt-