- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Changing required field in file
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
тАО03-14-2005 12:48 AM
тАО03-14-2005 12:48 AM
Changing required field in file
I have some file which has all volumes of a particular field listed.
Fields are:
vg
vg
..
..
..
vg
I want to change all these by
vg
vg
..
..
vg
Is it possible to do it one shot. I can do it using vi or sed 1 field at a time.
Thanks and regards
Prashant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-14-2005 12:55 AM
тАО03-14-2005 12:55 AM
Re: Changing required field in file
This assume that NO other lines start with lowercase vg.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-14-2005 01:09 AM
тАО03-14-2005 01:09 AM
Re: Changing required field in file
I have
/dev/vg
/dev/vg
..
..
..
/dev/vg
Like this above. I didnt put rv completly, they are raw vols. I want to change ENVNAME[1-10] to
ENVNAME[1-10].SNAP (please note (ENV and env are different.)
Thanks
Prashant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-14-2005 01:48 AM
тАО03-14-2005 01:48 AM
Re: Changing required field in file
Lets say your filename is /tmp/test. You can use one command to replace this.
sed 's/ENVNAME\>[1-9]/&.SNAP/' /tmp/test
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-14-2005 01:59 AM
тАО03-14-2005 01:59 AM
Re: Changing required field in file
One correction you may have issue with vg
sed 's/ENVNAME\>[1-9][0]/&.SNAP/' /tmp/test | sed 's/ENVNAME\>[1-9]/&.SNAP/' | sed 's/\.SNAP0/0/'
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-14-2005 02:41 AM
тАО03-14-2005 02:41 AM
Re: Changing required field in file
Thanks
Prashant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-14-2005 03:16 AM
тАО03-14-2005 03:16 AM
Re: Changing required field in file
I used your format in /tmp/test file
/dev/vg
/dev/vg
/dev/vg
/dev/vg
/dev/vg
/dev/vg
/dev/vg
/dev/vg
/dev/vg
/dev/vg
And I get following output with
#sed 's/ENVNAME\>[1-9][0]/&.SNAP/' /tmp/test | sed 's/ENVNAME\>[1-9]/&.SNAP/' | sed 's/\.SNAP0/0/'
/dev/vg
/dev/vg
/dev/vg
/dev/vg
/dev/vg
/dev/vg
/dev/vg
/dev/vg
/dev/vg
/dev/vg
Please let me know if this is not your expected output, or if you are having syntax error with above command?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-14-2005 04:07 AM
тАО03-14-2005 04:07 AM
Re: Changing required field in file
Thanks and regards
Prashant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-14-2005 04:38 AM
тАО03-14-2005 04:38 AM
Re: Changing required field in file
perl -pie 's{(/vg......\d+)/}{$1.SNAP/}' yourfile
This will apply the change directly to "yourfile" so you may want a backup of it before trying this routine. Since your ENVNAME may have digits, I'm assuming that they are 6 characters long.
HTH
-- Rod Hills
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-14-2005 05:14 AM
тАО03-14-2005 05:14 AM
Re: Changing required field in file
( not expected and also if I remove that 1 not set..
Thx
Prashant