Sponsored Content
Top Forums Shell Programming and Scripting Merging Files in UNIX shell script Post 302769592 by rdrtx1 on Tuesday 12th of February 2013 05:51:23 PM
Old 02-12-2013
try also:
Code:
for section in HDR BODY FTR
do
   ls -1 *$section* | while read file
   do
      new_file="${file%-${section}*}"-"${file#*${section}-}"
      cat "$file" >> "$new_file"
   done
done

This User Gave Thanks to rdrtx1 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to delete files in UNIX using shell script

Hi, I have the following task to perform using shell script. The user will provide a directory name along with a date. The script will delete all the files in the specified directory that was created earlier to that date. Also it should display the number of files that has been deleted. ... (7 Replies)
Discussion started by: theguy16
7 Replies

2. UNIX for Dummies Questions & Answers

Merging 2 .CSV files in Unix

I need a little help as I am a complete novice at scripting in unix. However, i am posed with an issue...:eek: i have two csv files in the following format@ FILE1.CSV: HEADER HEADER Header , , HEADER 001X ,,200 002X ,,300 003X ... (6 Replies)
Discussion started by: chachabronson
6 Replies

3. Shell Programming and Scripting

merging of 2 files AWK, SHELL or something else

I have 2 files pipe delimted and want to merge them based on a key e.g file 1 123|xxx|yyy|zzz 345|xab|yzy|zyz 456|sss|ttt|foo file 2 123|hhh|ggg|xxx 345|ddd|www|ddd|fff 456|ddd|sss|sss|eee so if the key is the first field, and the result should be file 1 with field 2 from file 2... (24 Replies)
Discussion started by: klut
24 Replies

4. Shell Programming and Scripting

Shell script for merging lines in a loop

Dear All, I need a script to merge lines of an input file in a loop, please guide me for the script or one liner(awk, sed, tr, shell, perl). I/P File------------------------- APaul,,,,SDH,,23,,,PPH,,2 ,,,,KKH,,19,,,MMH,,12, ,,,,CCH,,22,,,MNH,,19, ,,,,TCH,,55,,,NNH,,67,... (3 Replies)
Discussion started by: ashis.tewari
3 Replies

5. Shell Programming and Scripting

Script for merging files

I am facing a strange situation where I need to collect logs and consolidate them. All logs are under say /tmp/useless and all logs are under subdir of the form IPaddresses_x_y eg: /tmp/useless/105.52.34.246_3_1 /tmp/useless/105.52.1.118_0_10 There are several logs under each... (2 Replies)
Discussion started by: zpn
2 Replies

6. Shell Programming and Scripting

AWK Script For Merging Text Files

Hello, I am trying to merge data from two text files. One file (File1) contains a listing of data which includes the trial number in Column 5, while the other text file (File2) contains what category the trial belongs to. Here is a snippet of what File1 looks like. 1 Arrow_ST 9.738 0.905... (2 Replies)
Discussion started by: Jahn
2 Replies

7. Shell Programming and Scripting

Script for merging six files into one

Hi all Need little help from you my aim is like merging the output of 6 files (log_files) And merge it into the one master file tell me the script for this please thanks in advance Please reply in mail if possible <email removed> Regards: zimmy (1 Reply)
Discussion started by: zimmyyash
1 Replies

8. Shell Programming and Scripting

Merging Very large CSV files in Unix

Hi, I have two very large CSV files, which I want to merge (equi-join) based on a key (column). One of the file (say F1) would have ~30 MM records and 700 columns. The other file (~f2) would have same # of records and lesser columns (say 50). I want to create an output file joining on a... (3 Replies)
Discussion started by: student_007
3 Replies

9. Shell Programming and Scripting

Merging two files in UNIX

Hi Experts, Need urgent solution for a problem. I have two files file1 and file2. file1 is tab separated and file2 is comma separated. I need to merge both the files into single file based on CUST_ID by retaining the headers of file1 Matching CUST_IDs should be placed one below the other in... (11 Replies)
Discussion started by: bharathbangalor
11 Replies

10. Shell Programming and Scripting

Help getting a UNIX shell script to look at multiple files.

Hey everyone! I made a shell script that would go through a file and replace any phrase or letter with another phrase or letter. Helps update variable names or values. The following code is this: #!/bin/sh Word1="$1" Replace1="$2" File1="$3" arg=$( echo "$Word1" | sed 's:\:\\&:g' )... (3 Replies)
Discussion started by: rebmonk
3 Replies
ldsseek(3)						     Library Functions Manual							ldsseek(3)

NAME
ldsseek, ldnsseek - seek to an indexednamed section of a common object file SYNOPSIS
#include <stdio.h> #include <filehdr.h> #include <syms.h> #include <ldfcn.h> int ldsseek (ldptr, sectindx) LDFILE *ldptr; unsigned short sectindx; int ldnsseek (ldptr, sectname) LDFILE *ldptr; char *sectname; DESCRIPTION
ldsseek seeks to the section specified by sectindx of the common object file currently associated with ldptr. ldnsseek seeks to the section specified by sectname. ldsseek and ldnsseek return SUCCESS or FAILURE. If sectindx is greater than the number of sections in the object file, ldsseek fails; if there is no section name corresponding with sectname, ldnsseek fails. If there is no section data for the specified section or if it can- not seek to the specified section, either function fails. NOTE: The first section has an index of one. The program must be loaded with the object file access routine library libmld.a. RELATED INFORMATION
ldclose(3), ldopen(3), ldshread(3), ldfcn(4). delim off ldsseek(3)
All times are GMT -4. The time now is 02:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy