Sponsored Content
Top Forums Shell Programming and Scripting bash: How to split up a file based on another? Post 302563790 by byte711 on Wednesday 12th of October 2011 07:16:23 AM
Old 10-12-2011
That's awesome radoulov. I discovered last night that it's a little more complex than I thought.

The SPLIT_BY.txt file will have 2 columns, the first is the volume_group_name and the second is still the split_by value.

ie, SPLIT_BY.txt contents:
Code:
vgaaa 2
vgbbb 5
vgccc 1
vgddd 7

End results would be:
FILE1.txt
Code:
vgcreate vgaaa FILE01
vgextend vgaaa FILE02

FILE2.txt
Code:
vgcreate vgbbb FILE03
vgextend vgbbb FILE04
vgextend vgbbb FILE05
vgextend vgbbb FILE06
vgextend vgbbb FILE07

FILE3.txt
Code:
vgcreate vgccc FILE08

FILE4.txt
Code:
vgcreate vgddd FILE09
vgextend vgddd FILE10
vgextend vgddd FILE11
vgextend vgddd FILE12
vgextend vgddd FILE13
vgextend vgddd FILE14
vgextend vgddd FILE15

The first 'FILE##' within 'FILE#.txt' will start off with a 'vgcreate' and IF there are more than one 'FILE##' it'll start off with 'vgextent', and so on for the rest. Is this possible? Thanks!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split a file based on a pattern

Dear all, I have a large file which is composed of 8000 frames, what i would like to do is split the file into 8000 single files names file.pdb.1, file.pdb.2 etc etc each frame in the large file is seperated by a "ENDMDL" flag so my thinking is to use this flag a a point to split the files... (4 Replies)
Discussion started by: Mish_99
4 Replies

2. Shell Programming and Scripting

Split file based on field

Hi I have a large file 2.6 million records and I am trying to split the file based on last column. I am doing awk -F"|" '{ print > $NF }' filename1 After around 1000 splits it gives me a error awk: can't open file 3332332423 input record number 1068, file filename1 source... (6 Replies)
Discussion started by: s_adu
6 Replies

3. Shell Programming and Scripting

Split the file based on date value

Hi frnds, I have flat file as . Say : output-file1.txt Output-file2.txt (1 Reply)
Discussion started by: Gopal_Engg
1 Replies

4. Shell Programming and Scripting

How to split file based on subtitle

Hi, unix Gurus, I want to split file based on sub_title. for example: original file fruit apple watermelon meat pork fish beef expected result file file1 fruit apple watermelon file2 meat pork fish beef. (4 Replies)
Discussion started by: ken002
4 Replies

5. Shell Programming and Scripting

Split file based on size

Hi Friends, Below is my requirement. I have a file with the below structure. 0001A1.... 0001B1.. .... 0001L1 0002A1 0002B1 ...... 0002L1 .. the first 4 characters are the sequence numbers for a record, A record will start with A1 and end with L1 with same sequence number. Now the... (2 Replies)
Discussion started by: diva_thilak
2 Replies

6. Shell Programming and Scripting

Split the file based on pattern

Hi , I have huge files around 400 mb, which has clob data and have diffeent scenarios: I am trying to pass scenario number as parameter and and get required modified file based on the scenario number and criteria. Scenario 1: file name : scenario_1.txt ... (2 Replies)
Discussion started by: sol_nov
2 Replies

7. Shell Programming and Scripting

Split file based on records

I have to split a file based on number of lines and the below command works fine: split -l 2 Inputfile -d OutputfileMy input file contains header, detail and trailor info as below: H D D D D TMy split files for the above command contains: First File: H DSecond File: ... (11 Replies)
Discussion started by: Ajay Venkatesan
11 Replies

8. Shell Programming and Scripting

Split File based on different conditions

I need to split the file Conditions: Ignore any record that either starts with 1 or 9 Split the file at position 404 , if position 404 is abc or def then write all the records in a file > File 1 , the remaining records should go in to a file > File 2 Further I want to split the... (7 Replies)
Discussion started by: protech
7 Replies

9. UNIX for Advanced & Expert Users

Split one file to many based on pattern

Hello All, I have records in a file in a pattern A,B,B,B,B,K,A,B,B,K Is there any command or simple logic I can pull out records into multiple files based on A record? I want output as File1: A,B,B,B,B,K File2: A,B,B,K (9 Replies)
Discussion started by: deal1dealer
9 Replies

10. Shell Programming and Scripting

Split the File based on Size

I have a file that is about 7 GB in size. The requirement is I should split the file equally in such a way that the size of the split files is less than 2Gb. If the file is less than 2gb, than nothing needs to be done. ( need to done using shell script) Thanks, (4 Replies)
Discussion started by: rudoraj
4 Replies
VGEXTEND(8)						      System Manager's Manual						       VGEXTEND(8)

NAME
vgextend - add physical volumes to a volume group SYNOPSIS
vgextend [-A|--autobackup {y|n}] [-d|--debug] [-h|-?|--help] [--restoremissing] [-f|--force] [-t|--test] [-v|--verbose] [PHYSICAL DEVICE OPTIONS] VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...] DESCRIPTION
vgextend allows you to add one or more initialized physical volumes (see pvcreate(8)) to an existing volume group to extend it in size. Moreover, it allows you to re-add a physical volume that has gone missing previously, due to a transient device failure, without re-ini- tialising it. Use vgextend --restoremissing to that effect. If PhysicalDevicePath was not previously configured for LVM with pvcreate(8), the device will be initialized with the same default values used with pvcreate(8). If non-default pvcreate(8) values are desired, they may be given on the commandline with the same options as pvcre- ate(8). See PHYSICAL DEVICE OPTIONS for available options. Note that the restore-related options such as --restorefile, --uuid and --physicalvolumesize are not available. If a restore operation is needed, use pvcreate(8) and vgcfgrestore(8). OPTIONS
See lvm(8) for common options. PHYSICAL DEVICE OPTIONS
The following options are available for initializing physical devices in the volume group. These options are further described in the pvcreate(8) man page. -f, --force -y, --yes -Z, --zero {y|n} --labelsector sector --metadatasize size --metadataignore {y|n} --pvmetadatacopies copies --dataalignment alignment --dataalignmentoffset alignment_offset Examples Extends the existing volume group "vg00" by the new physical volumes (see pvcreate(8)) "/dev/sda4" and "/dev/sdn1". vgextend vg00 /dev/sda4 /dev/sdn1 SEE ALSO
lvm(8), vgcreate(8), vgreduce(8), pvcreate(8) Sistina Software UK LVM TOOLS 2.02.105(2)-RHEL7 (2014-03-26) VGEXTEND(8)
All times are GMT -4. The time now is 05:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy