- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk for lvcreate
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
тАО08-25-2004 07:08 AM
тАО08-25-2004 07:08 AM
I want to create a text file for creating LVs on the system using this file. It has two lines. The Record Separator starting with vg (e.g., vgidx). So each record is two lines.
What I am looking for is that the output txt file should produce like this; using the first two lines of the file:
lvcreate -L 4080 -n idx01_4g vgidx
--------------
vgidx
idx01_4g 4080
vgidx
idx02_4g 4080
vgidx
idx03_4g 4080
vgidx
idx04_4g 4080
vgidx
idx05_4g 4080
vgidx
idx06_4g 4080
vgidx
idx07_4g 4080
---
Thanks
Rasheed.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2004 07:19 AM
тАО08-25-2004 07:19 AM
Re: awk for lvcreate
perl -ne 'chomp; /^vg/ && do { $vg=$0l } ; /^id/ && do { ($id,$sz)=split(" ",$_); print "lvcreate -L $sz -n $id $vg\n"; }' inputfile
HTH
-- Rod Hills
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2004 07:34 AM
тАО08-25-2004 07:34 AM
Re: awk for lvcreate
cat input-file | awk '/^vg/ {VG=$1} /^id/ {print "lvcreate -L 4080 -n " $1" "$2" "VG}' >output-file
HTH,
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2004 07:36 AM
тАО08-25-2004 07:36 AM
Re: awk for lvcreate
this will be the way:
cat input-file | awk '/^vg/ {VG=$1} /^id/ {print "lvcreate -L "$2" -n " $1" "VG}' >output-file
Sorry for the mistake,
Peter
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2004 07:40 AM
тАО08-25-2004 07:40 AM
Re: awk for lvcreate
I think it should be:
cat input-file | awk '/^vg/ {VG=$1} /^id/ {print "lvcreate -L " $2 " -n " $1" "
VG}' >output-file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2004 07:46 AM
тАО08-25-2004 07:46 AM
Re: awk for lvcreate
You are right, I saw it myself and posted the correction just before you ;-)
Regards,
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2004 06:30 PM
тАО08-27-2004 06:30 PM
Re: awk for lvcreate
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2004 07:03 PM
тАО08-27-2004 07:03 PM
Re: awk for lvcreate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2004 08:37 PM
тАО08-27-2004 08:37 PM
SolutionThe awk examples above work with your given sample data. If you have VGs and LVs that don't use the above naming convention you can try this:
awk '{vg=$0; getline; print "lvcreate -L " $2 " -n " $1 " " vg}' test.txt
I created a sample file with the following data:
1vgidx1
idx01_4g 4080
2vgidx2
idx02_4g 6120
3vgidx3
idx03_4g 8160
And the output of the command above was:
$ awk '{vg=$0; getline; print "lvcreate -L " $2 " -n " $1 " " vg}' test.txt
lvcreate -L 4080 -n idx01_4g 1vgidx1
lvcreate -L 6120 -n idx02_4g 2vgidx2
lvcreate -L 8160 -n idx03_4g 3vgidx3
This should work without worrying about the VG or LV starting characters.
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2004 08:39 PM
тАО08-27-2004 08:39 PM
Re: awk for lvcreate
no syntaxcheck, and no empty lines required !
awk '{ VG=$1
getline
print "lvcreate -L " $2 " -n " $1 " " VG
}' infile
lvcreate -L 4080 -n idx01_4g vgidx
lvcreate -L 4080 -n idx02_4g vgidx
lvcreate -L 4080 -n idx03_4g vgidx
lvcreate -L 4080 -n idx04_4g vgidx
lvcreate -L 4080 -n idx05_4g vgidx
lvcreate -L 4080 -n idx06_4g vgidx
lvcreate -L 4080 -n idx07_4g vgidx
Trick is to store the VG-Name in VG and to read the next line and after that generate the output line.
Hope this helps
Volker