Sponsored Content
Top Forums Shell Programming and Scripting merging two .txt files by alternating x lines from file 1 and y lines from file2 Post 302525229 by pravin27 on Thursday 26th of May 2011 05:53:42 AM
Old 05-26-2011
Could this help you? (Code not tested)
Code:
#!/bin/sh
i=0
j=6
k=0
while read line1
do
    echo $line1
    i=$i+1
    if [ $i -eq 10 ]
    then
        awk -v start=$k -v end=$j  'NR > start && NR <= end' file2
        k=$j
        j=$j+6
        i=0
    fi
done < file1


Last edited by pravin27; 05-26-2011 at 07:09 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merging files with AWK filtering and counting lines

Hi there, I have a couple of files I need to merge. I can do a simple merge by concatenating them into one larger file. But then I need to filter the file to get a desired result. The output looks like this: TRNH 0000000010941 ORDH OADR OADR ORDL ENDT 1116399 000000003... (2 Replies)
Discussion started by: Meert
2 Replies

2. Shell Programming and Scripting

Urgent Need Help! Merging lines in .txt file

I need to write a script that reads through an input .txt file and replaces the end value with the end value of the next line for lines that have distance <=4000. The first label line is not actually in the input. In the below example, 3217 is the distance from the end of the first line to the... (12 Replies)
Discussion started by: awknerd
12 Replies

3. Shell Programming and Scripting

Merging lines in a file

Hi, I want to merge the lines starting with a comma symbol with the previous line of the file. Input : cat file.txt name1,name2 ,name3,name4 emp1,emp2,emp3 ,emp4 ,emp5 user1,user2 ,user3 Output name1,name2,name3,name4 emp1,emp2,emp3,emp4,emp5 (9 Replies)
Discussion started by: mohan_tuty
9 Replies

4. Shell Programming and Scripting

Matching lines across multiple csv files and merging a particular field

I have about 20 CSV's that all look like this: "","","","","","","","","","","","","","","",""What I've been told I need to produce is the exact same thing, but with each file now containing the start_code from every other file where the email matches. It doesn't matter if any of the other... (1 Reply)
Discussion started by: Demosthenes
1 Replies

5. Shell Programming and Scripting

sed to cp lines x->y from 1.txt into lines a->b in file2.txt

I have one base file, and multiple target files-- each have uniform line structure so no need to use grep to find things-- can just define sections by line number. My question is quite simple-- can I use sed to copy a defined block of lines (say lines 5-10) from filename1.txt to overwrite an... (3 Replies)
Discussion started by: czar21
3 Replies

6. UNIX for Dummies Questions & Answers

find lines in file1.txt not found in file2.txt memory problem

I have a diff command that does what I want but when comparing large text/log files, it uses up all the memory I have (sometimes over 8gig of memory) diff file1.txt file2.txt | grep '^<'| awk '{$1="";print $0}' | sed 's/^ *//' Is there a better more efficient way to find the lines in one file... (5 Replies)
Discussion started by: raptor25
5 Replies

7. Shell Programming and Scripting

Merging multiple files using lines from one file

I have been working of this script for a very long time and I have searched the internet for direction but I am stuck here. I have about 3000 files with two columns each. The length of each file is 50000. Each of these files is named this way b.4, b.5, b.6, b.7, b.8, b.9, b.10, b.11, b.12... (10 Replies)
Discussion started by: iconig
10 Replies

8. Shell Programming and Scripting

Merging multiple lines to columns with awk, while inserting commas for missing lines

Hello all, I have a large csv file where there are four types of rows I need to merge into one row per person, where there is a column for each possible code / type of row, even if that code/row isn't there for that person. In the csv, a person may be listed from one to four times... (9 Replies)
Discussion started by: RalphNY
9 Replies

9. UNIX for Beginners Questions & Answers

Merging specifc lines of three files into one?

Recall that nc-county-pop.dat has 100 lines, and each line corresponds to a county. The files girls.dat and boys.dat each has 50 lines. Assume that the girls come from the first 50 counties and each county has only one girl. That is the first girl comes from the first county, the second girl comes... (1 Reply)
Discussion started by: novicep11
1 Replies

10. Shell Programming and Scripting

Merging two files each contain 16 lakh lines on HP-UX 11.11 system

Hello All , I am trying to merge two files each contain 16 lakh lines ..My requirement is i have merge after every 14 lines of each file . Like from file1 14 lines then after after 14 lines form file2 ..so i wrote below script . It is working for small files ,but large files script not... (10 Replies)
Discussion started by: Phani369
10 Replies
smix(1) 							Linux System Manual							   smix(1)

NAME
smix - A Simple LINUX Mixer Program SYNOPSIS
smix [-v] [-h] [-o file] [-i file] [-m file] [-s] [command(s)] DESCRIPTION
smix , a simple mixer program that reports or controls the Mixer settings of /dev/mixer (or the specific mixer device file specified by the "-m file" option) from the command line parameter(s). The commands are detailed below, capitals showing the minimum abbreviation allowed. Upper or lower case can be used on the command line. All Volume settings are in range 0-100 (0 min, 100 max), but these are scaled to the mixers actual range, hence set volume may be slightly different. To see what devices/channels the mixer is configured with and to get a command summary, use smix -h SHow or ALL outputs the settings of the mixer. This is the default, if no command line parameters are given dev outputs the current settings for the mixer device named "dev" dev N or L,R sets mixer device 'dev' to volume N, or to separate left and right stereo volume L,R If device doesn't support stereo settings then max of L,R is used. The word off can be used instead of 0 and full can be used instead of 100. ALL N or L,R sets all mixer devices to specified volume setting (see above). INput dev set the DSP input to be 'dev' or 'NOne' to turn inputs off Verbose makes the program output the settings after doing the commands OPTIONS
-h show usage summary, which also lists the mixer devices and the possible input devices. -v be verbose - outputs the results of commands. Same as Verbose above -i file read commands from file -o file divert standard output to file. -m file use file instead of the default /dev/mixer . The file has to be a valid mixer device type. -s causes smix to output mixer settings etc in a form that can be read by smix to cause the same settings to set. This can be used to record the settings of all or part of the mixer into a file, change the settings, then get smix to reset the original settings by giving the file as an input file, see examples below. Use '-' as a filename to indicate standard input. EXAMPLES
smix Displays the current mixer devices and their current settings. smix -m /dev/mixer1 Displays the devices and their current settings for /dev/mixer1 smix input line1 line1 60 mic 0 show sets input to line1, line1 volume to 60 and mic volume to 0 (off) and shows the total resultant mixer settings. smix line1 60,0 show sets left line1 input to volume 60 and right line1 input to 0 (off) and shows the resultant output. smix -i /etc/mixer.default set the mixer settings from smix commands in /etc/mixer.default . smix -i - take mixer commands from stdin, with output to stdout. If stdin and stdout is the keyboard and display, then mixer commands can by typed and executed interactively and control is retained of the mixer while smix is running. smix -s -o mixer.conf record the current settings of the default mixer in file mixer.conf in a form that can be fed back in to smix. smix -i mixer.conf -o /dev/null take the file saved, as above, and reset the mixer settings, without doing any output. OPTIONAL CONFIGURATION FILES
Three possible configuration files can be used: a LOCAL config file (usually in current directory), a HOME config file in user's $HOME directory and a GLOBAL config file. All the siggen suite of programs are compiled with the names of the config files built in. By default the configuration files are: ./.siggen.conf is the LOCAL config file. $HOME/.siggen.conf is the HOME config file. /etc/siggen.conf is the GLOBAL config file. smix -h will indicate which config files will be searched for. The config files do not have to exist. If they exist and are readable by the program they are used, otherwise they are simply ignored. The config files are always searched for configuration values in the order LOCAL, HOME, GLOBAL. This allows a scheme where the sysadmin sets up default config values in the GLOBAL config file, but allows a user to set some or all different values in their own HOME config file, and to set yet more specific values when run from a particular directory. If no configuration files exist, the program provides builtin default values, and these values can be set by appropriate command line options and flags. See siggen.conf(5) for details of the configuration files. smix currently looks for configuration values MIXERFILE, VERBOSE. MIXERFILE allows the name of the mixer device file to be changed from /dev/mixer VERBOSE sets whether or not to run in verbose mode. SEE ALSO
siggen.conf(5) All the other mixer programs that float around the internet. BUGS
COPYING
Copyright 1995-2008 Jim Jackson The software described by this manual is covered by the GNU General Public License, Version 2, June 1991, issued by : Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be included in translation instead of in the original English. AUTHOR
Jim Jackson Email: jj@franjam.org.uk Release 2 20 Feb 1998 smix(1)
All times are GMT -4. The time now is 08:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy