Sponsored Content
Full Discussion: Break a large file
Top Forums Shell Programming and Scripting Break a large file Post 302777751 by jacobs.smith on Friday 8th of March 2013 10:58:05 AM
Old 03-08-2013
Break a large file

Hi Friends,

I have the following file and I would like to split it after every line that starts with
Code:
done

The file is like this

Code:
cat script

#!/bin/bash
#
# Name: name
# Task: name
#
#$ -N name
#$ -S /bin/bash
#$ -m be
#$ -M xxx
#$ -e xxx
#$ -o xxx

cd /path

#!/bin/bash

while read line
do
  	c=$(program ${line} | wc -l )
        line=${line/:/ }
        line=${line/-/ }
        echo "${line} ${c}"
done < input > output

#!/bin/bash
#
# Name: name
# Task: name
#
#$ -N name
#$ -S /bin/bash
#$ -m be
#$ -M xxx
#$ -e xxx
#$ -o xxx

cd /path

#!/bin/bash

while read line
do
  	c=$(program ${line} | wc -l )
        line=${line/:/ }
        line=${line/-/ }
        echo "${line} ${c}"
done < input1 > output1

After each done, there can be a blank line or an immediate line starting after it. Whatever it is, I would like to split the file based on the done criteria.So, from the above input, I get two output files.

Code:
cat script1

#!/bin/bash
#
# Name: name
# Task: name
#
#$ -N name
#$ -S /bin/bash
#$ -m be
#$ -M xxx
#$ -e xxx
#$ -o xxx

cd /path

#!/bin/bash

while read line
do
  	c=$(program ${line} | wc -l )
        line=${line/:/ }
        line=${line/-/ }
        echo "${line} ${c}"
done < input > output

Code:
cat script2

#!/bin/bash
#
# Name: name
# Task: name
#
#$ -N name
#$ -S /bin/bash
#$ -m be
#$ -M xxx
#$ -e xxx
#$ -o xxx

cd /path

#!/bin/bash

while read line
do
  	c=$(program ${line} | wc -l )
        line=${line/:/ }
        line=${line/-/ }
        echo "${line} ${c}"
done < input1 > output1

So, far I tried this

Code:
awk '/done/{x="F"++i;next}{print > x;}' script

But, I see an error saying

Code:
awk: null file name in print or getline
 input record number 1, file om
 source line number 1

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Break a file into separate files

Hello I am facing a scenario where I have a file with XML content and I am running shell script over it. But the problem is the XML is getting updated with new services. In the below scenario, my script takes values from the xml file from one service name say ABCD. Since there are multiple, it is... (8 Replies)
Discussion started by: chiru_h
8 Replies

2. UNIX for Dummies Questions & Answers

to break a file into 2 files after matching a pattern.

Hi, i need to break a file into 2 files afetr matching a pattern for ex. there is a fil, file .txt which contains here i need to look for mat $ demon if it matches then i need to transfer the data into another file till the line in which a "d6s" comes,and i have to delete tat line... (3 Replies)
Discussion started by: manit
3 Replies

3. Shell Programming and Scripting

Perl break a file

I am trying to break a large file into smaller ones, with the break defined by the character "*". The following is the code I have so far which breaks the input file on every line instead of at the "*" character. Input file: 1 2 3 4 *5 6 7 8 9 Code: #!/usr/bin/perl... (2 Replies)
Discussion started by: cold_Que
2 Replies

4. Shell Programming and Scripting

How to remove line break character in a file

Hi, we are trying to process a csv file,in which we are getting data with line breaks.How to remove the line break character in the file? when i try to print the line break charcter using od -c,it gives as '\n' character for both line break and line feed. Please provide your valuable... (6 Replies)
Discussion started by: cnraja
6 Replies

5. Shell Programming and Scripting

Page Break in large file

Hi, The shell script inserting the millions of rows into target flat file system and handling the line number for each line. We need a page break line after every 10,000 lines. is there any command to insert a page break line into target file. (3 Replies)
Discussion started by: koti_rama
3 Replies

6. Shell Programming and Scripting

Page Break in a file for printing

Hi, We have 1lac records in source file and unix script will genarate around 1000 files. From target location the files are taking for printing on physical papers. the page size limitation : 256 Lines Can you please tell me how to insert the page break in a flat file for printer. (5 Replies)
Discussion started by: koti_rama
5 Replies

7. UNIX for Dummies Questions & Answers

add a string to a file without line break

I searched and found "echo -n" and "printf" are solution for this, but they are not here: $ echo "hello" >> test $ cat test hello $ echo -n "world" >> test $ cat test hello world $ echo -n " seriously?" >> test $ cat test hello world seriously? This is not successful... (15 Replies)
Discussion started by: stunn3r
15 Replies

8. Shell Programming and Scripting

Line Break Issue in XML file

Hi Experts, Kindly help me to resole the line break issue mentioned below sample xml file: sample source File: ============== <?!New XML File><NEWRECORDS xmlns... (3 Replies)
Discussion started by: UnniVKN
3 Replies

9. Shell Programming and Scripting

Break Column nth in a CSV file into two

Hi Guys, Need help with logic to break Column nth in a CSV file into two for e.g Refer below the second column as the nth column "abcd","","type/beta-version" need output in a following format "abcd","/place/asia/india/mumbai","/product/sw/tomcat","type/beta-version" ... (5 Replies)
Discussion started by: awk-admirer
5 Replies

10. Shell Programming and Scripting

Break output file into three files

Help! :) I am getting an output file that looks similar to below. EMAIL_ADDR ----------------------------------------------------------------------------------- user@gmail.com DATABASENAME ----------------------------------------------------------------------------------- db1 db2 db3... (6 Replies)
Discussion started by: cpolikowsky
6 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 09:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy