Sponsored Content
Full Discussion: Concatenate Numerous Files
Operating Systems Linux Fedora Concatenate Numerous Files Post 302723181 by sudon't on Monday 29th of October 2012 03:04:46 PM
Old 10-29-2012
I knew that, eventually, someone reading this thread would get frustrated and whip up a script to solve all my problems. It must be the same feeling I get when I meet someone who can barely read or write. Script writing is so far beyond my capabilities that it feels like cheating, somehow. ; )
The way they have the files set up might be a problem for your script. Indeed, it is thee problem.
Code:
-bash $ cat OTfilelistsorted.txt
.....
./01_Old Testament/01_Genesis/Genesis8.txt
./01_Old Testament/01_Genesis/Genesis9.txt
./01_Old Testament/01_Genesis/Genesis10.txt
./01_Old Testament/01_Genesis/Genesis11.txt
.....

Each book constitutes a directory, while each chapter constitutes a numbered file. Genesis, for instance, is broken up into fifty separate files. Correct me if I'm wrong, but it seems like your script is expecting each book to be one file. Could your embedded list contain a wildcard character? Even so, it seems to me we still have the problem of sorting. As you can see, they used single digit enumeration. But I'm going to try to fix the actual filenames, first.

---------- Post updated at 03:04 PM ---------- Previous update was at 02:36 PM ----------

OK, found out that rename is a perl script someone made up. Downloaded the code, et voila!
Code:
-bash $ ls
Genesis1.txt	Genesis19.txt	Genesis28.txt	Genesis37.txt	Genesis46.txt
Genesis10.txt	Genesis2.txt	Genesis29.txt	Genesis38.txt	Genesis47.txt
Genesis11.txt	Genesis20.txt	Genesis3.txt	Genesis39.txt	Genesis48.txt
Genesis12.txt	Genesis21.txt	Genesis30.txt	Genesis4.txt	Genesis49.txt
Genesis13.txt	Genesis22.txt	Genesis31.txt	Genesis40.txt	Genesis5.txt
Genesis14.txt	Genesis23.txt	Genesis32.txt	Genesis41.txt	Genesis50.txt
Genesis15.txt	Genesis24.txt	Genesis33.txt	Genesis42.txt	Genesis6.txt
Genesis16.txt	Genesis25.txt	Genesis34.txt	Genesis43.txt	Genesis7.txt
Genesis17.txt	Genesis26.txt	Genesis35.txt	Genesis44.txt	Genesis8.txt
Genesis18.txt	Genesis27.txt	Genesis36.txt	Genesis45.txt	Genesis9.txt
-bash $ ls | rename 's/(?<=[a-z])(?=[0-9]\.txt)/0/g'
-bash $ ls
Genesis01.txt	Genesis11.txt	Genesis21.txt	Genesis31.txt	Genesis41.txt
Genesis02.txt	Genesis12.txt	Genesis22.txt	Genesis32.txt	Genesis42.txt
Genesis03.txt	Genesis13.txt	Genesis23.txt	Genesis33.txt	Genesis43.txt
Genesis04.txt	Genesis14.txt	Genesis24.txt	Genesis34.txt	Genesis44.txt
Genesis05.txt	Genesis15.txt	Genesis25.txt	Genesis35.txt	Genesis45.txt
Genesis06.txt	Genesis16.txt	Genesis26.txt	Genesis36.txt	Genesis46.txt
Genesis07.txt	Genesis17.txt	Genesis27.txt	Genesis37.txt	Genesis47.txt
Genesis08.txt	Genesis18.txt	Genesis28.txt	Genesis38.txt	Genesis48.txt
Genesis09.txt	Genesis19.txt	Genesis29.txt	Genesis39.txt	Genesis49.txt
Genesis10.txt	Genesis20.txt	Genesis30.txt	Genesis40.txt	Genesis50.txt
-bash $

This should give us properly sorted lists. Now, a little find/replace to eliminate spaces.... I am now having fun.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deleting numerous files

Hi there, I have numerous files in a directory (approx 2500) that I want to delete although I get the following:- Server> rm *.* Arguments too long Is there a proper way of deleting this rather than breaking it down further through the list of files rm *10.* rm *11.* rm *12.* ... (10 Replies)
Discussion started by: Hayez
10 Replies

2. UNIX for Dummies Questions & Answers

How to concatenate all files.

Hi, I'm totally new to Unix. I'm an MVS mainframer but ran into a situation where a Unix server I have available will help me. I want to be able to remotely connect to another server using FTP, login and MGET all files from it's root or home directory, logout, then login as a different user and do... (1 Reply)
Discussion started by: s80bob
1 Replies

3. Shell Programming and Scripting

Script to concatenate several files

I need a script to concatenate several files in one step, I have 3 header files say file.S, file.X and file.R, I need to concatenate these 3 header files to data files, say file1.S, file1.R, file1.X so that the header file "file.S" will be concatenated to all data files with .S extentions and so on... (3 Replies)
Discussion started by: docaia
3 Replies

4. Shell Programming and Scripting

Concatenate rows in to 2 files

I have 2 files FILEA 1232342 1232342 2344767 4576823 2325642 FILEB 3472328 2347248 1237123 1232344 8787890 I want the output to go into a 3rd file and look like: FILEC 1232342 3472328 (1 Reply)
Discussion started by: unxusr123
1 Replies

5. Shell Programming and Scripting

Concatenate files

I have directory structure sales_only under which i have multiple directories for each dealer example: ../../../Sales_Only/xxx_Dealer ../../../Sales_Only/yyy_Dealer ../../../Sales_Only/zzz_Dealer Every day i have one file produce under each directory when the process runs. The requirement... (3 Replies)
Discussion started by: mohanmuthu
3 Replies

6. Shell Programming and Scripting

Concatenate files

Hi, I want to create a batch(bash) file to combine 23 files together. These files have the same extension. I want the final file is save to a given folder. Once it is done it will delete the 23 files. Thanks for help. Need script. (6 Replies)
Discussion started by: zhshqzyc
6 Replies

7. Shell Programming and Scripting

Concatenate files

I have a file named "file1" which has the following data 10000 20000 30000 And I have a file named "file2" which has the following data ABC DEF XYZ My output should be 10000ABC 20000DEF (3 Replies)
Discussion started by: bobby1015
3 Replies

8. UNIX for Dummies Questions & Answers

Concatenate Several Files to One

Hi All, Need your help. I will need to concatenate around 100 files but each end of the file I will need to insert my name DIRT1228 on each of the file and before the next file is added and arrived with just one file for all the 100files. Appreciate your time. Dirt (6 Replies)
Discussion started by: dirt1228
6 Replies

9. UNIX for Dummies Questions & Answers

Concatenate files

Hi I am trying to learn linux step by step an i am wondering can i use cat command for concatenate files but i want to place context of file1 to a specific position in file2 place of file 2 and not at the end as it dose on default? Thank you. (3 Replies)
Discussion started by: iliya24
3 Replies

10. UNIX for Dummies Questions & Answers

Concatenate files and delete source files. Also have to add a comment.

- Concatenate files and delete source files. Also have to add a comment. - I need to concatenate 3 files which have the same characters in the beginning and have to remove those files and add a comment and the end. Example: cat REJ_FILE_ABC.txt REJ_FILE_XYZ.txt REJ_FILE_PQR.txt >... (0 Replies)
Discussion started by: eskay
0 Replies
X2SYS_MERGE(1gmt)					       Generic Mapping Tools						 X2SYS_MERGE(1gmt)

NAME
x2sys_merge - Merge an updated COEs tables SYNOPSIS
x2sys_merge -Amain_COElist.d -Mnew_COElist.d DESCRIPTION
x2sys_merge will read two crossovers data base and output the contents of the main one updated with the COEs in the second one. The second file should only contain updated COEs relatively to the first one. That is, it MUST NOT contain any new two tracks intersections (This point is NOT checked in the code). This program is useful when, for any good reason like file editing NAV correction or whatever, one had to recompute only the COEs between the edited files and the rest of the database. -A Specify the file main_COElist.d with the main crossover error data base. -M Specify the file new_COElist.d with the newly computed crossover error data base. OPTIONS
No space between the option flag and the associated arguments. EXAMPLES To update the main COE_data.txt with the new COEs estimations saved in the smaller COE_fresh.txt, try x2sys_merge -ACOE_data.txt -MCOE_fresh.txt > COE_updated.txt SEE ALSO
x2sys_binlist(1), x2sys_cross(1), x2sys_datalist(1), x2sys_get(1), x2sys_init(1), x2sys_list(1), x2sys_put(1), x2sys_report(1) GMT 4.5.7 15 Jul 2011 X2SYS_MERGE(1gmt)
All times are GMT -4. The time now is 03:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy