Sponsored Content
Top Forums Shell Programming and Scripting concatenating selected lines of multiple files Post 302366828 by laiko on Friday 30th of October 2009 12:06:48 PM
Old 10-30-2009
concatenating selected lines of multiple files

Thanks much! That works! I got a new requirement today in addition to that. I have to attach a header to it. I have a file header whose contents (which may vary) I need to prefix to the concatenation. For example:

FileHeader:

Code:
FILES AS OF TODAY:
HEADER LINE1
HEADER LINE2

And the result should be:

Code:
FILES AS OF TODAY:
HEADER LINE1
HEADER LINE2
    START HERE
    line1
    line2
    START HERE
    line111
    line222
    START HERE
    line11
    line22

I can only think of doing this:

Code:
awk 'FNR==1{f=0}/START HERE/{f=1}f' * > concat.txt
cat concat.txt >> FileHeader

Any better way to do this????
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Concatenating multiple lines to one line if match pattern

Hi all, I've been working on a script which I have hit a road block now. I have written a script using sed to extract the below data and pumped into another file: Severity............: MAJORWARNING Summary: System temperature is out of normal range. Severity............: MAJORWARNING... (13 Replies)
Discussion started by: phixsius
13 Replies

2. Shell Programming and Scripting

Running a command on multiple selected files in nautilus script

I am trying to make a script to convert drg files to wav and so far i have this #!/bin/bash drg2sbg "$*" -o "$*".sbg sbagen -Wo "/home/nick/Desktop/I-Doser Wave Files/"$*"" "$*".sbg rm "$*".sbg cd "/home/nick/Desktop/I-Doser Wave Files" rename 's/\.drg$/\.wav/' *.drg exit the drg2sbg and... (2 Replies)
Discussion started by: Nickbowlingdude
2 Replies

3. Shell Programming and Scripting

Concatenating lines of separate files using awk or sed

For example: File 1: abc def ghi jkl mno pqr File 2: stu vwx yza bcd efg hij klm nop qrs I want the reult to be: abc def ghistu vwx yza jkl mno pqrbcd efg hij klm nop qrs (4 Replies)
Discussion started by: tamahomekarasu
4 Replies

4. Shell Programming and Scripting

awk: switching lines and concatenating lines?

Hello, I have only recently begun with awk and need to write this: I have an input consisting of a couple of letters, a space and a number followed by various other characters: fiRcQ 9( ) klsRo 9( ) pause fiRcQ 9( ) pause klsRo continue 1 aPLnJ 62( ) fiRcQ continue 5 ... and so on I... (7 Replies)
Discussion started by: Borghal
7 Replies

5. Shell Programming and Scripting

trying to print selected fields of selected lines by AWK

I am trying to print 1st, 2nd, 13th and 14th fields of a file of line numbers from 29 to 10029. I dont know how to put this in one code. Currently I am removing the selected lines by awk 'NR==29,NR==10029' File1 > File2 and then doing awk '{print $1, $2, $13, $14}' File2 > File3 Can... (3 Replies)
Discussion started by: ananyob
3 Replies

6. Shell Programming and Scripting

Problem in concatenating multiple files from subdirectories

I want to concatenate multiple files recursively from sub-directories intoone file in Linux. I saved the following script as script.sh in $HOME/testing1 where I have several subdirectories and .txt files into them. I ran script.sh from the command prompt of $HOME/testing1 as ./script.sh. But it... (3 Replies)
Discussion started by: raj284
3 Replies

7. Shell Programming and Scripting

Error in concatenating multiple files from subdirectories

I want to concatenate multiple files recursively from sub-directories intoone file in Linux. I saved the following script as script.sh in $HOME/testing1 where I have several subdirectories and .txt files into them. I ran script.sh from the command prompt of $HOME/testing1 as ./script.sh. But it... (3 Replies)
Discussion started by: raj284
3 Replies

8. Shell Programming and Scripting

Concatenating 2 lines from 2 files having matching strings

Hello All Unix Users, I am still new to Unix, however I am eager to learn it.. I have 2 files, some lines have some matching substrings, I would like to concatenate these lines into one lines, leaving other untouched. Here below is an example for that.. File 1 (fasta file): >292183... (6 Replies)
Discussion started by: Mohamed EL Hadi
6 Replies

9. UNIX for Dummies Questions & Answers

Read in Multiple log files and output selected variables and values to cvs file

I have several problems with my problems: I hope you can help me. 1) the If else statement I am getting an error message. My syntax must be incorrect because the entire statement is throwing an error. For example in filew.log if these items don't exist Memsize, SASFoundation and also if... (0 Replies)
Discussion started by: dellanicholson
0 Replies

10. Shell Programming and Scripting

Removing carriage returns from multiple lines in multiple files of different number of columns

Hello Gurus, I have a multiple pipe separated files which have records going over multiple Lines. End of line separator is \n and records going over multiple lines have <CR> as separator. below is example from one file. 1|ABC DEF|100|10 2|PQ RS T|200|20 3| UVWXYZ|300|30 4| GHIJKL|400|40... (7 Replies)
Discussion started by: dJHa
7 Replies
VPL2MOD.1(1)						      Sword Module Utilities						      VPL2MOD.1(1)

NAME
vpl2mod - tool to convert verse per line source to SWORD module SYNOPSIS
vpl2mod SOURCE PATH [0|1] [0|1] DESCRIPTION
This utility is used to create SWORD module from the verse per line formated source. The resulting module will be saved in the path specified. OPTIONS
[0|1] [0|1] The first option indicates whether to prepend verse references or not. The second option is to indicate whether module is NT only or not. NOTE
With no verse references source file must contain exactly 31102 lines. This is KJV verse count plus heading for the module, testament, book and chapter. An example snippet follows: MODULE HEADER OLD TESTAMENT HEADER GENESIS HEADER CHAPTER 1 HEADER In the beginning... This example implies there must also be a chapter 2 header, Exodus header, New Testament header, etc. If there is no text for the header, a black line must, at least, hold place. With verse references, source file must simply contain any number of lines, that begin with the verse reference for which it is an entry, e.g.: gen 1:0 CHPATER 1 HEADER get 1:1 In the beginning... Authors This manual page was written by Dmitrijs Ledkovs <dmitrij.ledkov@gmail.com> for Debian project but may be used by others. SEE ALSO
SWORD 1.6.2+dfsg 2012-02-22 VPL2MOD.1(1)
All times are GMT -4. The time now is 04:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy