- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Variable manipulating
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
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
тАО04-04-2004 09:21 PM
тАО04-04-2004 09:21 PM
Variable manipulating
My Problem:
from a variable with this content:
/dev/dsk/c0t0d0 /cdrom cdfs ro,suid 0 0
i need the:
/dev/dsk/c0t0d0
and:
/cdrom
in to different variables.
How can i do this?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2004 09:28 PM
тАО04-04-2004 09:28 PM
Re: Variable manipulating
# VAR1="dev/dsk/c0t0d0 /cdrom cdfs ro,suid 0 0"
# DEV=$(echo $VAR1 | awk '{print $1}')
# echo $DEV
# CDR=$(echo $VAR1 | awk '{print $2}')
# echo $CDR
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2004 09:38 PM
тАО04-04-2004 09:38 PM
Re: Variable manipulating
Is that file containing only one line or multiple line
here i am giving example for file containing one line.
*)to get /dev/dsk/c0t0d0:
cut -f 1 -d " "
*)to get /cdrom
cut -f 2 -d " "
If u have more than one line use,
*) extract the line comes with cdrom
cat
And use above cut to get from tmpfile
ALL THE BEST
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2004 09:42 PM
тАО04-04-2004 09:42 PM
Re: Variable manipulating
| read v1 v2 v3 v4 v5 v6
echo $v1
/dev/dsk/c0t0d0
echo $v2
/cdrom
Regards,
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2004 09:45 PM
тАО04-04-2004 09:45 PM
Re: Variable manipulating
Try this, if u want to extract Entire Col.
for first col.
#cut -f 1 -d " "
for 2nd col.
#cut -f 2 -d " "
If u want to extract only Both col. use character count option in cut respectively.
#cut -f 1,2 -d " "
d option for delimitor.
f option for field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2004 10:02 PM
тАО04-04-2004 10:02 PM
Re: Variable manipulating
VAR1 ---- /dev/dsk/c0t0d0
VAR2 ---- /cdrom
...
...
Regds,
Kaps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2004 11:31 PM
тАО04-04-2004 11:31 PM
Re: Variable manipulating
var="/dev/dsk/c0t0d0 /cdrom cdfs ro,suid 0 0"
var1=`echo $var | cut -f1 -d " "`
var2=`echo $var | cut -f2 -d " "`
echo $var1
echo $var2
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2004 11:37 PM
тАО04-04-2004 11:37 PM
Re: Variable manipulating
echo $var | read var1 var2 trash
echo $var1
/dev/dsk/c0t0d0
echo $var2
/cdrom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-05-2004 01:52 AM
тАО04-05-2004 01:52 AM
Re: Variable manipulating
str="/dev/dsk/c0t0d0 /cdrom cdfs ro,suid 0 0"
set -A ary $str
dev=${ary[0]}
mnt=${ary[1]}
HTH
-- Rod Hills