Sponsored Content
Top Forums Shell Programming and Scripting Split single file into multiple files using pattern matching Post 302674493 by aster007 on Thursday 19th of July 2012 10:05:12 PM
Old 07-19-2012
Not the best solution...but should work
Considering file as your input file

Code:
i=1

while read LINE
do
    END_OF_FILE=`echo $LINE | awk -F "|" '{print $1}'`
    
    if [[ $END_OF_FILE != "SE" ]]
    then
        echo $LINE >> file_${i}
    else
        echo $LINE >> file_${i}
        
        i=`expr $i + 1`
    fi
done < file

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

split a single sql file into multiple files

Hi,I have a single sql file containing many create table ddl's.Example: CREATE TABLE sec_afs ( rpt_per_typ_c char(1) NOT NULL, rpt_per_typ_t varchar(20) NULL, LOCK ALLPAGES go EXEC sp_primarykey 'sec_afs', rpt_per_typ_c go GRANT SELECT ON sec_afs TO developer_read_only... (5 Replies)
Discussion started by: smarter_aries
5 Replies

2. Shell Programming and Scripting

Split single file into multiple files based on the number in the column

Dear All, I would like to split a file of the following format into multiple files based on the number in the 6th column (numbers 1, 2, 3...): ATOM 1 N GLY A 1 -3.198 27.537 -5.958 1.00 0.00 N ATOM 2 CA GLY A 1 -2.199 28.399 -6.617 1.00 0.00 ... (3 Replies)
Discussion started by: tomasl
3 Replies

3. Shell Programming and Scripting

Split the single file lines into multiple files

Let's assume that I have a file name called ‘A' and it has 100 lines in it and would like to split these 100 lines into 4 files as specified bellow. INPUT: Input file name A 1 2 3 4 5 6 7 8 9 ........100 Output: 4 output files (x,y,z,w) File x should contains (Skip 4 lines)... (15 Replies)
Discussion started by: subbarao25
15 Replies

4. Shell Programming and Scripting

Split a file into multiple files based on the input pattern

I have a file with lines something like. ...... 123_start ...... ....... 123_end .... ..... 456_start ...... ..... 456_end .... ..... 789_start .... .... 789_end (6 Replies)
Discussion started by: abinash
6 Replies

5. UNIX for Dummies Questions & Answers

Split single file into n number of files

Hi, I am new to unix. we have a requirement here to split a single file into multiples files based on the number of people available for processing. So i tried my hand at writing some code as below. #!/bin/bash var1=`wc -l $filename` var2=$var1/$splitno split -l $var2 $1 Please help me... (6 Replies)
Discussion started by: quirkguy
6 Replies

6. Shell Programming and Scripting

split XML file into multiple files based on pattern

Hello, I am using awk to split a file into multiple files using command: nawk '{ if ( $1 == "<process" ) { n=split($2, arr, "\""); file=arr } print > file }' processes.xml <process name="Process1.process"> ... (3 Replies)
Discussion started by: chiru_h
3 Replies

7. Shell Programming and Scripting

Creating single pattern for matching multiple files.

Hi friends, I have a some files in a directory. for example 856-abc 856-def 851-abc 945-def 956-abc 852-abc i want to display only those files whose name starts with 856* 945* and 851* using a single pattern. i.e 856-abc 856-def 851-abc 945-def the rest of the two files... (2 Replies)
Discussion started by: Little
2 Replies

8. Shell Programming and Scripting

awk script issue redirecting to multiple files after matching pattern

Hi All I am having one awk and sed requirement for the below problem. I tried multiple options in my sed or awk and right output is not coming out. Problem Description ############################################################### I am having a big file say file having repeated... (4 Replies)
Discussion started by: kshitij
4 Replies

9. Shell Programming and Scripting

Split a single file into multiple files based on a value.

Hi All, I have the sales_data.csv file in the directory as below. SDDCCR; SOM ; MD6546474777 ;05-JAN-16 ABC ; KIRAN ; CB789 ;04-JAN-16 ABC ; RAMANA; KS566767477747 ;06-JAN-16 ABC ; KAMESH; A33535335 ;04-JAN-16 SDDCCR; DINESH; GD6674474747 ;08-JAN-16... (4 Replies)
Discussion started by: ROCK_PLSQL
4 Replies

10. Shell Programming and Scripting

Group Multiple Lines on SINGLE line matching pattern

Hi Guys, I am trying to format my csv file. When I spool the file using sqlplus the single row output is wrapped on three lines. Somehow I managed to format that file and finally i am trying to make the multiple line on single line. The below command is working fine but I need to pass the... (3 Replies)
Discussion started by: RJSKR28
3 Replies
vzlist(8)							    Containers								 vzlist(8)

NAME
vzlist - show various information about containers SYNOPSIS
vzlist [-a | -S] [-n] [-H] [-o name[,name...] | -1] [-s [-]name] [-h pattern] [-N pattern] [-d pattern] [CTID [CTID ...]] vzlist -L | --list vzlist --help DESCRIPTION
This utility is used for listing containers and their parameters. By default only running containers are listed. If one or more CTIDs are specified, only specified containers are displayed. For the fields that can have many values (e.g. ip), all the values are displayed only for the last (i.e. leftmost) column; otherwise, only the first value is shown. OPTIONS
-a, --all List all containers. -S, --stopped List only not running containers (including the ones with status shown as mounted or suspended). -n, --name Display container names instead of hostnames. -H, --no-header Suppress displaying the header row. -o, --output field[,field...] Display only the specified fields (see Standard fields subsection below). -1 Synonym for -H -octid, i.e. only show container IDs, one per line. -s, --sort [-]field Sort by the value of field (possible arguments are the same as for -o). The - before the field name means sorting in the reverse order. Output filters List of CTs can be further filtered using the following options. For patterns one can use the same wildcards as in shell (i.e. *, ?, and []). Note: to avoid expansion of wildcards by the shell, one have to escape the pattern by either putting it into single quotes (like 'a*a') or by adding a backslash before the wildcard character (like a*a). -h, --hostname pattern List only containers whose hostnames matches the pattern. -N, --name_filter pattern List only containers whose names matches the pattern. -d, --description pattern List only containers with descriptions matching the pattern. Possible fields -L, --list list all available format specifiers that can be used for both output (-o, --output) and the sorting order (-s, --sort). For the user beancounter fields, if suffix is not specified, current usage (a.k.a. "held") value is show. One can also use the fol- lowing suffixes: .m maxheld .b barrier .l limit .f fail counter For the disk quota fields, if suffix is not specified, current usage is shown. One can also use the following suffixes: .s soft limit .h hard limit EXAMPLES
vzlist -o ctid,kmemsize,kmemsize.l -s kmemsize Show CTIDs, kmemsize usage, and kmemsize limit for all running containers, sorted by the kmemsize usage. EXIT STATUS
Returns 0 upon success. COPYRIGHT
Copyright (C) 2000-2011, Parallels, Inc. Licensed under GNU GPL. OpenVZ 4 Jul 2011 vzlist(8)
All times are GMT -4. The time now is 11:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy