Sponsored Content
Full Discussion: grep multiple lines
Top Forums Shell Programming and Scripting grep multiple lines Post 302096911 by aigles on Monday 20th of November 2006 11:43:11 AM
Old 11-20-2006
You can do something like that (not tested) :
Code:
awk '
     /VG Name/ {vg_name = $3 }
     /vpath/ && vg_name { print $0 ; vg_name = "" }
    ' input_file


Jean-Pierre.

Last edited by aigles; 11-20-2006 at 03:31 PM.. Reason: Correction of case on VG line selection
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep on multiple lines

I 'm trying to grep 2 fieldds on 2 differnt lines. Like this: psit > file egrep -e '(NS|ES)' $file. Not working. If this succeeds then run next cmd else exit. Pls Help Gundu (13 Replies)
Discussion started by: gundu
13 Replies

2. Shell Programming and Scripting

grep multiple lines

Hey guys: I've been meaning to post this question for awhile...it is regarding grep. Let's say for example that the following entry is in logxx: Wed Feb 2 07:44:11 <vsm> 91030 Line 5 Severity 1 Vps 6 Call Answered - DN:8753101 CLID:5164665761 PI:83 If I do a grep 91030... (27 Replies)
Discussion started by: cdunavent
27 Replies

3. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

4. UNIX for Dummies Questions & Answers

grep in multiple lines

hi i have kind of below text in a file. I want to get a complete paragraph starting with START and ending with before another START) which has a particular string say XYZ or ABC START XYZ hshjghkjh 45 ljkfd fldjlj d jldf START 3493u ABC 454 4545454 4545454 45454 4545454 START ...... (3 Replies)
Discussion started by: reldb
3 Replies

5. UNIX for Advanced & Expert Users

grep across multiple lines

How do you grep 'select * from table_name' string from a script if the select * and from table_name are on 2 different lines ? like select * from table_name Any help would be greatly appreciated !!! Thanks RDR (4 Replies)
Discussion started by: RDR
4 Replies

6. UNIX for Dummies Questions & Answers

Grep multiple lines

I want to grep multiple lines from a text file. I want to grep all lines containing X,Y and NA in a single command. How do I go about doing that? This is what my text files look like: rs1983866 0.0983 10 100016313 rs1983865 0.5994 X 100016339 rs1983864 0.3272 11 100017453 rs7077266... (2 Replies)
Discussion started by: evelibertine
2 Replies

7. Shell Programming and Scripting

grep from multiple lines in several gz files

Hello all, I have been struggling to get grep work to my requirements. Basically I have to filter out patterns spread across multiple lines over hundreds of .gz files in a folder. And the output needs to be piped to a file. Here is the example: folder name: logs files in this folder:... (4 Replies)
Discussion started by: mandhan
4 Replies

8. Shell Programming and Scripting

Grep and exttract multiple lines

Hello: I am trying to use grep in cygwin to do the following, however I am unable to get the output in the desired format. Please see and let me know how to solve this Input log file 20140403 07:29:26 IN:CTRL=:TYP=TYP1:DCN=DCN1:DATA= 20140403 07:25:26 IN:CTRL=:TYP=TYP1:DCN=DCN2:DATA=... (4 Replies)
Discussion started by: wincrazy
4 Replies

9. Shell Programming and Scripting

Grep and display multiple lines

Hi guys, I have a log file that generates multiple logs about a query. <query time='2016-04-13 13:01:50.825'> <PagingRequestHandler> <Before>brand:vmu</Before> <After>brand:vmu</After> </PagingRequestHandler> <GroupDeviceFilterHandler> <Before>brand:vmu</Before> ... (3 Replies)
Discussion started by: Junaid Subhani
3 Replies

10. Shell Programming and Scripting

Exclude multiple lines using grep

Hi, I'm working on a shell script that reports service status on a database server. There are some services that are in disabled status that the script should ignore and only check the services that are in Enabled status. I output the service configuration to a file and use that information to... (5 Replies)
Discussion started by: senthil3d
5 Replies
vgmodify(1M)															      vgmodify(1M)

NAME
vgmodify - handle physical volume size changes and modify configuration parameters of an existing LVM volume group SYNOPSIS
vgmodify Options for Volume Groups Version 1.0 max_pe] max_lv] max_pv] vg_name bootable max_pe] max_lv] max_pv] vg_name pv_path ... max_pe] max_lv] max_pv] vg_name [pv_path...] vg_name bootable vg_name pv_path ... vg_name [pv_path...] dlc_size vg_name pv_path vg_name bootable vg_name pv_path ... vg_conf_path vg_name pv_path ... vgmodify Options for Activated Volume Groups Version 2.0 and Higher vg_name [pv_path...] dlc_size vg_name pv_path vg_size vg_name DESCRIPTION
The command allows the user to modify an existing volume group (vg_name). The modifications that can perform depend on the version of the volume group and whether or not the volume group is activated. The following changes can be performed for volume groups version 1.0: o Detect and handle physical volume size changes. If the volume group is activated, the option of must be specified to take advantage of increased physical volume sizes. If the volume group is deactivated, will implicitly handle increased physical volume sizes. o Prepare a physical volume for a LUN contraction (dlc_size setting). o Modify the maximum number of physical extents that can be allocated per physical volume (max_pe setting) (see vgcreate(1M) o Modify the maximum number of physical volumes that the volume group can contain (max_pv setting) (see vgcreate(1M) o Modify the maximum number of logical volumes that the volume group can contain (max_lv setting) (see vgcreate(1M) o Change a physical volume type from boot to non-boot or vice versa (see pvcreate(1M) Note that making a physical volume non-bootable will increase the space available on that device for LVM configuration data. However, even a single bootable physical volume in the volume group will restrict the max_pv and max_pe settings available. For volume groups version 1.0, all the physical volumes associated with the volume group must be available for the command to succeed. Also, if the command is interrupted before it completes, recovery steps might be required. See the section for details. The following changes can be performed for volume groups version 2.0: o Detect and handle physical volume size changes. The option must be specified to take advantage of increased physical volume size. o Prepare a physical volume for a LUN contraction (dlc_size setting). o Modify the maximum volume group size (vg_size setting) (see vgcreate(1M) For volume groups version 2.0 and higher, is allowed only when the volume group is in an activated state. Options and Arguments The command recognizes the following arguments and options: vg_name The path name of a volume group. pv_path The character (raw) device path name of a physical volume. Refer to the and options for the physical volume list usage. Perform volume group reconfiguration when the volume group is activated. This option is required if the volume group is activated. The command will fail if this option is used on a deactivated volume group. For version 1.0 volume groups, this option is ignored when used with the and options. Applicable to volume groups version 1.0 only. Make the physical volumes specified in the pv_paths list bootable or non-bootable. The option is mutually exclusive with the and options. bootable can have one of the following values: Change pv_path list from non-bootable to bootable. Change pv_path list from bootable to non-bootable. See the description of the option in pvcreate(1M). Making a physical volume non-bootable will increase the space available on that device for LVM configuration data. However to fully use that space all the physical volumes in the volume group should be non-bootable. A single bootable physical volume in the volume group will restrict the available configuration settings. A physical volume can only be made bootable if either all extents on it are unused or it was previously con- verted from a bootable device and the space is still unused. If a physical volume is being made bootable then use and to complete the process (see lvlnboot(1M) and mkboot(1M)). Prepare the physical volume for LUN contraction to dlc_size. Exactly one pv_path must be specified with the option. The option cannot be used in conjunction with any other option except for and The unit for dlc_size is specified as a suffix. The recognized values for the suffix are (megabytes), (giga- bytes), (terabytes), and (petabytes). If no suffix is supplied, then (megabytes) is assumed. A dlc_size of 512 terabytes would be specified as 512t. Only whole numbers are accepted. The size should be at least 1 megabyte, and no greater than a volume group version dependent maximum; use the command to determine the maximum size for a physical volume. Reconfigure an activated volume group to take advantage of physical volume size increase. This option must be used with the option. The option cannot be used in conjunction with the and options. If pv_path is not specified, will account for size increase of all physical volumes in the volume group. Applicable to volume groups version 1.0 only. Set the maximum number of physical extents that can be allocated from any of the physical volumes in the volume group (see vgcreate(1M) The maximum number of physical extents can range from the current highest physical extent in use on any physical volume in the volume group (1 if none in use) up to 65535. The option displays a table of possible max_pe values for vg_name. Applicable to volume groups version 1.0 only. Set the maximum number of logical volumes that the volume group is allowed to contain (see vgcreate(1M) The maximum number of logical volumes can range from the current highest logical volume number in use (1 if none in use) to 255. Note that changing this value has little impact on the size of the LVM configuration data. Applicable to volume groups version 1.0 only. Allow renumbering of physical extents on physical volumes. This only applies to physical volumes that have allocated extents. By default, physical extent numbers will be unchanged by Renumbering physical extents changes the allocation of the first physical extent, if it is free, from user to LVM configuration data and vice-versa. This will often have a considerable impact on the space available for the LVM configuration data on each physical volume and, therefore, the possible settings for the volume group parameters. No user data is moved during that process, only the LVM numbering of physical extents changes. When the first extent is being reallocated from user to LVM configuration data, the physical extent numbers are decreased. This will only occur if the first extent is free. For example a logical volume using physical extents 10 to 20 from a physical volume that has its first extent reallocated to LVM configuration data will use the physical extents 9 to 19 after the modification. User data is not moved. When the first extent is being reallocated from LVM configuration to user data, the physical extent numbers are increased. For example a logical volume using physical extents 10 to 20 from a physical volume that has its first extent re-allocated to user data will use the physical extents 11 to 21 after the modification. User data is not moved. Not all configurations allow renumbering. If this is the case then an error will be reported and a recommenda- tion to rerun without the option will be given. Applicable to volume groups version 1.0 only. Optimize the volume group settings. The maximum number of extents and physical volumes are adjusted upwards, where possible, to make full use of the space reserved on each physical volume for the LVM configuration data. This option cannot be used in conjunction with or Note: If renumbering is necessary, then rerun with and rather than Applicable to volume groups version 1.0 only. Set the maximum number of physical volumes that the volume group is allowed to contain (see vgcreate(1M) The maximum number of physical volumes can range from the current number of physical volumes in the volume group to 255. The option displays a table of possible max_pv values for vg_name. Applicable to volume groups version 1.0 only. Recover from a previous that either failed or was interrupted. The configuration in the vg_conf_file will be restored onto the pv_path list given. Report the effect of the other options being used. No changes will be made to the volume group. This option can be used on an active volume group. Only applicable to volume groups version 2.0 and higher. Changes the maximum size of the volume group. The unit for vg_size is specified as a suffix. The recognized values for the suffix are (megabytes), (gigabytes), (terabytes), and (petabytes). If no suffix is supplied, then (megabytes) is assumed. A vg_size of 512 terabytes would be specified as 512t. Only whole numbers are accepted. Applicable to volume groups version 1.0 only. Produce a table showing the optimal possible settings (max_pe, max_pv, and maximum disk size) for the volume group. This option can be used with and without to see a complete list of possible optimal settings. In certain cases the optimal settings will not be influenced by the extent renumbering and a suitable message will then be reported. Where adjacent max_pv values allow the same highest max_pe, only the highest max_pv is displayed; therefore, there may be gaps in the table. It is still possible to set a lower max_pv or max_pe than shown in the table but some of the LVM configuration space will not be used. is normally used to obtain the arguments for future command and/or options. Applicable to volume groups version 1.0 only. Verbose. Be verbose in reporting. Remarks for Volume Groups Version 1.0 o This command can be run on volume groups version 1.0 that are deactivated or activated in standalone or exclusive mode only. The com- mand will fail on volume groups activated in shared mode. o If of a volume group is interrupted while it is committing the configuration changes onto the disks, it may be necessary to re-apply the configuration to all the physical volumes. The script or the option must be used to accomplish this. For a deactivated volume group, to apply the new configuration using the restore script enter the following: Or to apply the old/original configuration, enter the following: For an activated volume group, the configuration file used with the restore script, or with the option, should correspond to the config- uration of the volume group before was run. o The root/boot volume group must be booted into maintenance mode before making changes (see boot(1M)). o If a volume group has any cluster lock physical volume, all reconfiguration and disk resize operations will fail, with one exception. A disk resize operation on a physical volume in an activated volume group will succeed if that specific physical volume does not have a cluster lock. o To expand the LVM configuration data to its maximum size, it may be necessary to reallocate the first physical extent from each physical volume from user to LVM configuration data. This will only be possible if the first extent is made free (see pvmove(1M)) and PE renum- bering is enabled via the option. o The LVM configuration data size is limited to the volume group extent size. Therefore, a maximum of one physical extent from each phys- ical volume can be reallocated from user data regardless of how many times is used on the volume group. o The attributes of an file can be viewed using the option of (see vgcfgrestore(1M)). o To take advantage of a physical volume size increase, it may be necessary to run to increase the maximum number of physical extents for the volume group. For a deactivated volume group, the command will implicitly consider the physical volume size increase. But for an activated volume group, the option should be used for to consider the physical volume size increase. o In general, a smaller number of physical volumes allows a larger number of physical extents. Likewise, a larger number of physical vol- umes constraints to a smaller number of physical extents. o For a deactivated volume group, the detection of physical volume size changes (LUN size expansion or contraction) is automatic, with the handling taking place unless the or options have been used. o For an activated volume group, the detection of a physical volume size increase (LUN size expansion) is not automatic. Instead, the option should be used for to detect and handle the physical volume size increase. o When used with the option, the option reports if the physical volume can be prepared for contraction to the specified size. If not, it displays the number of extents that need to be freed up on physical volume before it can be prepared for contraction to the specified size. In addition, it reports the smallest size to which the physical volume can be prepared for contraction without performing any operations on it, and the smallest size to which the physical volume can be prepared for contraction after compacting all the allocated physical extents on it by moving them up. o The changing of physical volume type (boot to non-boot or vice verse) is selected via the option and by specifying a list of physical volumes. Otherwise, no physical volume type changes are performed. o For an activated volume group, the and the options are mutually exclusive, since the physical volume list for the option is the list of the physical volumes to change from boot to non-boot or vice versa. The physical volume list for the and options is the list of physi- cal volumes to consider for increase and decrease in disk size, respectively. Remarks for Volume Groups Version 2.0 and Higher o This command can be run on volume groups version 2.0 and higher that are activated in standalone or exclusive mode. It can also run on volume groups activated in shared mode if they are 2.1 or higher. In the case of a shared volume group, the command must be issued on the server and the daemon must be running on all the nodes sharing the volume group. See lvmpud(1M). o If is interrupted while it is reconfiguring the physical volumes, or if the command fails, then the volume group is left in a consistent state (no special recovery is needed). To retry the operation, run the command with the desired options, and LVM will continue with the reconfiguration. o will fail if the volume group has a cluster lock physical volume. o The detection of a physical volume size increase (LUN size expansion) is not automatic. Instead, the option should be used to detect and handle the physical volume size increase. o When used with the option, the option reports if the physical volume can be prepared for contraction to the specified size. If not, it displays the number of extents that need to be freed up on physical volume before it can be prepared for contraction to the specified size. In addition, it reports the smallest size to which the physical volume can be prepared for contraction by removing all free extents on the physical volume. o When used with the option, the option reports if the volume can be reconfigured to the specified volume group size. If not, it displays the number of extents that need to be freed up on each physical volume before the volume group size can be reconfigured. In addition it reports the largest volume group size possible for each physical volume, and the largest volume group size possible when removing free extents. EXTERNAL INFLUENCES
Environment Variables determines the language in which messages are displayed. If is not specified or is null, it defaults to "C" (see lang(5)). If any internationalization variable contains an invalid setting, all internationalization variables default to "C" (see environ(5)). RETURN VALUE
returns one of the following values: Successful completion. Error condition occurred. EXAMPLES
Examples For a Volume Group Version 1.0 The volume group version 1.0 is deactivated in the following examples. Review the effect of setting a maximum of 6 physical volumes in the volume group: Set a maximum of 4000 physical extents per physical volume and a maximum of 50 physical volumes, and take advantage of extent renumbering if possible: Show a table of optimal possible settings for the volume group: Show a table of optimal possible settings for the volume group taking advantage of extent renumbering if possible: Show a table of optimal possible settings for the volume group, making the physical volume non-bootable: Review (do not change) the effect of choosing a maximum of 16 physical volumes, 8000 physical extents per physical volume, while making non-bootable (these values were selected from the table above) and be verbose: Apply the settings just reviewed: If the command is interrupted, restore the new configuration to all physical volumes in the volume group by entering: The volume group version 1.0 is activated in the following examples. Add extents to the physical volume that has been expanded by dynamic LUN expansion: Use the review option to determine if the physical volume can be prepared for LUN contraction to 4000 MB: Apply the LUN contraction setting that was just reviewed: Examples For a Volume Group Version 2.0 or Higher The volume group version 2.0 is activated in the following examples. Add extents to the physical volume that has been expanded by dynamic LUN expansion: Prepare physical volume for LUN contraction to size 4000 MB: Use the review option to determine if the volume group size can be increased to 256 terabytes: Apply the volume group size increase that was just reviewed: Increase the maximum size of the volume group to 256 terabytes, and also check if any physical volumes have been expanded by a dynamic LUN expansion: Decrease the volume group size to 2 terabytes, to free up extents on the physical volumes: WARNINGS
o Applicable to volume group version 1.0 only. Changing the type of a bootable physical volume will prevent booting from this device and, therefore, may create an unbootable system. o Do not restore a physical volume from a backup file produced prior to the latest changes. Doing so will result in attempts to attach the device to the volume group failing and may lead to activation failures. If there is any doubt about the configuration in the file, use to view the settings in the file. o Applicable to volume group version 1.0 only. If the command is interrupted prior to completing its operation, then restoration to all physical volumes in the volume group may be required. Use the restore script to accomplish this (see the section for more information). FILES
Holds the latest (new) configuration for the volume group. If completes successfully, this file contains the same new configuration as If was interrupted, this file contains the previous (old) configuration. A script created by before making any update, to be used if the command is interrupted while committing the configuration changes to the physical vol- umes. See the section for its usage. SEE ALSO
boot(1M), lvlnboot(1M), lvmpud(1M), mkboot(1M), pvcreate(1M), pvmove(1M), vgcfgbackup(1M), vgcfgrestore(1M), vgchange(1M), vgcreate(1M), vgdisplay(1M), vgextend(1M), vgreduce(1M), lvm(7). vgmodify(1M)
All times are GMT -4. The time now is 11:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy